The difference between Android ordered broadcasts and unordered broadcasts

Source: Internet
Author: User

BroadcastreceiverThe corresponding broadcasts are divided into two categories:General Broadcastand theOrderly Broadcast. General Broadcastthroughcontext.sendbroadcast ()method to send. It is completely asynchronous. The order of execution of all receivers receivers is indeterminate. Therefore, all receivers receivers receive broadcast in the order of uncertainty. This approach is more efficient. But Broadcastreceivercannot be usedSetresult Series,GetResult SeriesandAbort Series APIOrderly Broadcastis throughContext.sendorderedbroadcastto send. All receiver is executed sequentially. broadcastreceiver can use the setresult series function to pass results tothe next broadcastreceiver by GetResult series function to get The result of the last Broadcastreceiver return, and can abort the series function to let the system discard the broadcast let, Use of the broadcast is no longer transmitted to other broadcastreceiver. you can pass theIntent-filterset inandroid:priorityproperty to set the priority of receiver. Receiver with the same priority has an indeterminate order of execution. if Broadcastreceiver is registered in the code, and its Intent-filterhave the sameandroid:priorityProperties , first register will receive the broadcast first.

Orderly broadcast, that is, from the highest priority of the broadcast receiver start receiving, after the reception if not discarded, it is passed to the next secondary high-priority broadcast receiver processing, and so on, until the end.

The radio that receives text messages here is ordered broadcast, so you can set your own broadcast receiver level higher than the original system level, you can intercept text messages, and do not save the inbox, there will be no letter tone.

The implementation method is:

<receiver android:name= ". Smsreceiver ">
<intent-filter android:priority= ">"
<action android:name= "Android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>

Inside the android:priority= "100" is to set the level of the broadcast receiver, this value from 1000~-1000, the greater the value, the higher the priority level.

The difference between an ordered Android broadcast and an unordered broadcast

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.