androidservicebackground-serviceautostartbootcompleted

Android Starting Service at Boot Time , How to restart service class after device Reboot?


I need to start a service at boot time. I searched a lot. They are talking about Broadcastreceiver. As I am new to android development, I didn't get a clear picture about services on Android. Please provide some source code.


Solution

  • Create a BroadcastReceiver and register it to receive ACTION_BOOT_COMPLETED. You also need RECEIVE_BOOT_COMPLETED permission.

    Read: Listening For and Broadcasting Global Messages, and Setting Alarms