I want to start my application automatically when the phone boots. I declared BroadcastReceiver in the manifest file.
<receiver android:name=".Autostart"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I made a Java file for the recipient.
Autostart.java
public class Autostart extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { Intent pushIntent = new Intent(context, MushTouchActivity.class); pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(pushIntent); } }
}
But the application does not start when you turn on the phone. Can someone tell me what I am missing here?
source share