1. Layout
Default HelloWorld layout
2. Class
Bootcompletereceiver
Package Lpc.com.project522;import Android.content.broadcastreceiver;import Android.content.context;import android.content.intent;/** * Created by Administrator on 2015/12/23. */public class Bootcompletereceiver extends Broadcastreceiver { @Override public void OnReceive (Context Context, Intent Intent) { Intent = new Intent (context,mainactivity.class); Intent.setflags (Intent.flag_activity_new_task | intent.flag_activity_exclude_from_recents); Context.startactivity (intent); }}
3.
Manifest file
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" lpc.com.project522 "> <uses-permission android:name=" android.permission.RECEIVE_BOOT_ Completed "/> <application android:allowbackup=" true "android:icon=" @mipmap/ic_launcher "Android Oid:label= "@string/app_name" android:supportsrtl= "true" android:theme= "@style/apptheme" > <activ ity android:name= ". Mainactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&G T <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity& Gt <receiver android:name= ". Bootcompletereceiver "> <intent-filter> <action android:name=" android.intent.action.b Oot_completed "/> </intent-filter> </receiver> </applicAtion></manifest>
4, realize the effect, start the Mainactivity page of this app after booting
Android mobile phone set up activity