小编Pie*_*rre的帖子

RemoteServiceException: Context.startForegroundService 然后没有调用 Service.startForeground

我从以下异常输出Device Monitor

//FATAL EXCEPTION: main
//Process: com.xxx.yyy, PID: 11584
//android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()
//    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1881)
//    at android.os.Handler.dispatchMessage(Handler.java:105)
//    at android.os.Looper.loop(Looper.java:164)
//    at android.app.ActivityThread.main(ActivityThread.java:6944)
//    at java.lang.reflect.Method.invoke(Native Method)
//    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
//    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Run Code Online (Sandbox Code Playgroud)

我的应用程序中有 4 个服务,它们基本上都是这样的:

public class MyService extends Service {

    private static final int forgroundId = 55544433; //Unique for each Service
    private Notification notification;

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) { …
Run Code Online (Sandbox Code Playgroud)

service android android-notifications foregroundnotification

4
推荐指数
1
解决办法
2111
查看次数