我使用JobIntentService在后台创建服务。
它在android 8之前运行得很好。 但是在android 8上,会发生很多崩溃:
Caused by java.lang.IllegalArgumentException: Given work is not active: JobWorkItem {id = 3 intent = Intent {cmp = com.? Xxx.SettingService (has extras)} dcount = 1}
at android.app.job.JobParameters.completeWork (JobParameters.java:221)
at androidx.core.app.JobIntentService $ JobServiceEngineImpl $ WrapperWorkItem.complete (SourceFile: 268)
at androidx.core.app.JobIntentService $ CommandProcessor.doInBackground (SourceFile: 394)
at androidx.core.app.JobIntentService $ CommandProcessor.doInBackground (SourceFile: 383)
at android.os.AsyncTask $ 2.call (AsyncTask.java:333)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:636)
at java.lang.Thread.run (Thread.java:764)
我在stackoverflow上学到了同样的问题:
Getting crash on JobIntentService onComplete
但是这里我的ID = SettingService.class.hashCode(),所以我认为不会有巧合ID。