Android Boot from boot

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.