我是靠谱客的博主 眼睛大萝莉,这篇文章主要介绍Context.startForegroundService() did not then call Service.startForeground() 崩溃问题,现在分享给大家,希望可以做个参考。
问题:
android.app.RemoteServiceException
Context.startForegroundService() did not then call Service.startForeground()
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2002)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loop(Looper.java:192)
android.app.ActivityThread.main(ActivityThread.java:6893)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)
分析:
使用startForegroundService必须在5秒之内startForeground一下
解决方案:
//在启动的service里调用一下startForeground方法,2021这个值看你自己需求,0除外
startForeground(2021, new Notification());
最后
以上就是眼睛大萝莉最近收集整理的关于Context.startForegroundService() did not then call Service.startForeground() 崩溃问题的全部内容,更多相关Context.startForegroundService()内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复