Booting from Android

Source: Internet
Author: User

Booting from Android

Booting from Android can be divided into two steps:

1. Write a broadcastreceiver:

Java code
  1. Public class Bootreceiver extends Broadcastreceiver {
  2. private static final String TAG = "Bootreceiver";
  3. @Override
  4. public void OnReceive (context context, Intent Intent) {
  5. LOG.I (TAG, "boot auto-start");
  6. //Autoopenactivity is the main activity of the program
  7. //can also be a service running in the background
  8. Intent auto = new Intent (context, autoopenactivity.       Class);
  9. Auto.addflags (Intent.flag_activity_new_task);
  10. Context.startactivity (auto);
  11. }
  12. }

2. Register Broadcastreceiver and add permissions in Manifest.xml:

XML code
  1. <receiver android:name=". Bootreceiver " >
  2. <intent-filter >
  3. <action android:name="Android.intent.action.BOOT_COMPLETED" />
  4. <category android:name="Android.intent.category.HOME" />
  5. </intent-filter>
  6. </receiver>
XML code
    1. <uses-permission android:name="Android.permission.RECEIVE_BOOT_COMPLETED" />

Booting from Android

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.