We have number of situations in our development that we want our service or our app should be run as soon as Device Start, or after Boot Completed.
After boot completes the Android system broadcasts an intent with the action android.intent.action.BOOT_COMPLETED. And now all we need is an IntentReceiver, called a BroadcastReceiver, to listen and act on it.
So here is simple example where you can run your Activity or Service as soon as device Start.
first create simple activity as our favorite activity MainActivity :P
Now when the device finishes booting up, our BroadcastReceiver will receive the BOOT_COMPLETED action in the onReceive() method which is where we’ll start our service
2) registering the Service:
3) And The receiver needs to be declared in the manifest, e.g. with the following entry:
You can download complete example Here
Happy Codddding :)