Starting from Android O, you can not start a service from a background app without being blessed with an exception:
java.lang.IllegalStateException: Not allowed to start service Intent (my_service) : app is in background
If you still need to launch a service at device start up, you can now use the new JobIntentService.
Add your BroadcastReceiver and JobIntentService to your manifest:
Enqueue work for your JobIntentService:
Define your JobIntentService:
And that’s it. This will either directly start the service (when running on pre-O platforms) or enqueue work for it as a job (when running on O and later). No matter what the platform is, everything you pass in enqueueWork will ultimately appears in onHandleWork.