Android Notes (27) dynamic broadcast and static broadcast in Android

Source: Internet
Author: User

Broadcast receiver registration A total of two forms: static registration and dynamic registration.

The difference between the two and their received broadcasts:

1. Dynamically registered broadcasts are always faster than statically registered broadcasts, regardless of the high priority setting of the static registration, regardless of how low the priority of the dynamic registration >\

2. Dynamic registration broadcasts are not resident broadcasts, which means that the broadcast follows the activity's life cycle. Note: Remove the broadcast receiver before the activity ends.

Static registration is permanent, that is, when the application is closed, if there is information broadcast, the program will be automatically run by the system call.

3. Under the same priority, who starts first, who will receive the broadcast first.

Dynamic Registration Code:

Updatebroadcast  Newnew intentfilter ("Com.unit.UPDATE"); Registerreceiver ( Broadcast, filter);

Static registration code (added in config file):

<receiverAndroid:name= "Net.youmi.android.AdReceiver" >            <Intent-filter>                <ActionAndroid:name= "Android.intent.action.PACKAGE_ADDED" />                <DataAndroid:scheme= "Package" />            </Intent-filter> </receiver>

Android Notes (27) dynamic broadcast and static broadcast in Android

Related Article

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.