As with other broadcastreceiver, you need to configure the received broadcast information, and then configure the permissions
<receiver
Android:name= "Com.example.kaijistart.BootReceiver" >
<intent-filter >
<action android:name= "Android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<uses-permission android:name= "Android.permission.RECEIVE_BOOT_COMPLETED"/>
And then you can intent jump in the broadcastreceiver.
PackageCom.example.kaijistart;ImportAndroid.content.BroadcastReceiver;ImportAndroid.content.Context;Importandroid.content.Intent; Public classBootreceiverextendsBroadcastreceiver { PublicBootreceiver () {} @Override Public voidOnReceive (Context context, Intent Intent) {Intent it=NewIntent (context,mainactivity.class); //set up a new task stack, if we go from the system diagram punctuation, the system will create the activity stack,//but we don't have to click to create a task stack by ourselves now.it.setflags (Intent.flag_activity_new_task); Context.startactivity (IT); System.out.println ("Boot Up"); }}
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.kaijistart"Android:versioncode= "1"Android:versionname= "1.0" > <USES-SDKandroid:minsdkversion= "8"android:targetsdkversion= "+" /> <uses-permissionAndroid:name= "Android.permission.RECEIVE_BOOT_COMPLETED"/> <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" > <ActivityAndroid:name= "Com.example.kaijistart.MainActivity"Android:label= "@string/app_name" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> <receiverAndroid:name= "Com.example.kaijistart.BootReceiver" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.BOOT_COMPLETED"/> </Intent-filter> </receiver> </Application></Manifest>
Android four components of the Broadcastreceiver boot