Open
Description
Hi @eddieowens,
In Android 8 and up it's not possible to start services when your app is in background. Proof
If you try to do so, you get an error. Here is a log with stack trace:
I/RNBoundary: Handling geofencing event
I/RNBoundary: Geofence transition: 1
I/RNBoundary: Enter geofence event detected. Sending event.
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.sample.android, PID: 7277
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.sample.android/com.eddieowens.services.BoundaryEventHeadlessTaskService (has extras) }: app is in background uid UidRecord{8a05d06 u0a88 TRNB idle change:uncached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
at android.app.ContextImpl.startService(ContextImpl.java:1532)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at com.eddieowens.services.BoundaryEventJobIntentService.sendEvent(BoundaryEventJobIntentService.java:71)
at com.eddieowens.services.BoundaryEventJobIntentService.onHandleWork(BoundaryEventJobIntentService.java:46)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java: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:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
So the cause is this line.
Is this something we might hope to get fixed? And what would be ETA?
Thanks.
EDIT:
targetSdkVersion should be 26 or higher
Metadata
Metadata
Assignees
Labels
No labels