Principle: The Android system will issue a broadcast when it is powered on. This allows us to receive this broadcast and then launch our app. The broadcast receiver must be configured in XML because the broadcast receiver configured in the XML does 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 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"/>
That's all you can do.
I use the Red rice note test, to annoy the settings:
Click on "Settings" app to find your app click, pull to the bottom of the Rights management "automatic start" completed.