Home » Android » Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

Posted by: admin October 4, 2018 Leave a comment

Questions:

On application launch, app starts the service that should to do some network task.
After targeting API level 26, my application fails to start service on Android 8.0 on background.

Caused by: java.lang.IllegalStateException: Not allowed to start
service Intent {
cmp=my.app.tt/com.my.service
}: app is in background uid UidRecord{90372b1 u0a136 CEM idle procs:1
seq(0,0,0)}

as I understand it related to:
Background execution limits

The startService() method now throws an IllegalStateException if an
app targeting Android 8.0 tries to use that method in a situation when
it isn’t permitted to create background services.

in a situation when it isn’t permitted” – what it’s actually mean?? And how to fix it. I don’t want to set my service as “foreground”

Answers: