Android Boot service background run

Source: Internet
Author: User

Android Boot service background run Android boot will send a broadcast Android.intent.action.BOOT_COMPLETED, capture this broadcast, and then can do the appropriate operation, For example: Activate activity by capturing a boot broadcast, or service. 1, new Bootbroadcastreceiver class, inherit Broadcastreceiver. public class Bootbroadcastreceiver extends Broadcastreceiver { private final String action_boot = " Android.intent.action.BOOT_COMPLETED ";  @Overridepublic void OnReceive (context context, intent intent) {if ( Action_boot.equals (Intent.getaction ())) {System.out.println ("BOOT receiver start......\n"); Context.startservice ( New Intent (context, Collservice.class));}  } }2, androidmanifest configuration <receiver android:name= "Com.example.BootBroadcastReceiver" >< Intent-filter android:priority= "><action" android:name= "Android.intent.action.BOOT_COMPLETED"/>< /intent-filter><intent-filter android:priority= "><action android:name=" Android.intent.action.MEDIA_MOUNTED "/><action android:name=" Android.intent.action.MEDIA_EJECT "/>< Data android:scheme= "File"/></intent-filter> </receiver> 

Android boot up service background run

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.