Start activity on boot

Try this:

1] In AndroidManifest.xml file:

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

        android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
            <action android:name="android.intent.action.BOOT_COMPLETED" />

            <category android:name="android.intent.category.DEFAULT" />

2] Inside BroadcastReciever class with StartMyActivityAtBootReceiver as class name.

public void onReceive(Context context, Intent intent) {

    Intent i = new Intent(context, MainActivity.class);  


This worked for me. The difference in code is as follows:

  • android:permission=”android.permission.RECEIVE_BOOT_COMPLETED” inside receiver.
  • included “category android:name=”android.intent.category.DEFAULT” ” inside intent filter.
  • I am not checking the intent in onRecieve, as i know that code will be executed only if its true

Leave a Comment