Principle: The Android system will issue a broadcast when it is powered on. This will allow us to receive the broadcast and then launch our application. The broadcast receiver must be configured in XML, because the broadcast receivers configured in the XML do not exit with the application exiting.
Broadcast receivers:
Package Com.yangshidesign.boot;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;public class Bootreceiver extends Broadcastreceiver {@Overridepublic void OnReceive (Context Context, Intent Intent) {Intent i = new Intent (context, unityplayernativeactivity.class);//This must be added to Flagsi.setflags ( Intent.flag_activity_new_task); context.startactivity (i);}}
In manifest's application tag, configure:
<!--boot--><receiver android:name= "Com.yangshidesign.boot.BootReceiver" ><intent-filter>< Action android:name= "Android.intent.action.BOOT_COMPLETED"/><category android:name= " Android.intent.category.HOME "/></intent-filter></receiver>
Plus permissions:
<uses-permission android:name= "Android.permission.RECEIVE_BOOT_COMPLETED"/>
So that's it.
I use the Red rice note test, to annoy the setting:
Click on the Settings app to find your app Click, pull down the right management "self-initiated" finished.
Android Boot from boot