Android BroadcastReceiver, auto run service after reboot of device Android BroadcastReceiver, auto run service after reboot of device android android

Android BroadcastReceiver, auto run service after reboot of device


First do this

1) In your <manifest> element:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />


You forgot about the permissions

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />


Though all the above answers were correct, however from Android Oreo they put some limitation on Background Services.

Check Background Execution Limits to know more about background limits in Android O.

You can't start a Service directly from BroadCastReceiver when the application is in the background.

However, you can start a foreground service from the receiver by calling startForegroundService() or use JobIntentService as there is no such limitation with JobIntentService.