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