Detailed broadcast mechanism, broadcast receiver,android advanced Knowledge (ii).

Source: Internet
Author: User

Alas ... Yesterday wrote the blog, was the blog Park Management Group to abandon ... Sad!

Yesterday, thanks to the basic use of the radio, today go deep in the steak, tomorrow continue to write about the radio blog.

Much of what was said yesterday was about the reception of system broadcasts and the reception of system broadcasts, and now the use of custom broadcasts. Say the standard broadcast first, take yesterday static registration that example. It's the same thing everywhere. Replace the action in the manifest file with the action of our own definition.

<receiver android:name= ". Bootcompletereceiver ">            <intent-filter>                <action android:name=" com.example.broadcasttest.MY_ Broadcast "/>            </intent-filter>        </receiver>

Yesterday This example is listening to start the broadcast, now we let him listen to our own definition of a broadcast, only listen to not, but also need to send the line, below write how the broadcast is sent.

New Intent ("Com.example.broadcasttest.MY_BROADCAST"); Sendbroadcast (it);

OK, this is a complete custom broadcast, this side with intent to send, the receiver there will be reflected. All know that radio has an orderly broadcast in addition to standard broadcasts, but where do they differ? That is the way to send a different, just send is used:

Sendbroadcast (IT);


And the orderly broadcast is used: Sendorderdbroadcast (it,null);
That's the difference! In this method there are two parameters, the first argument is not needless to say, the second is a permission-related string.
Since it is an orderly broadcast, the recipient of an orderly broadcast must prioritize, so how do they sort it? It is also very simple, that is, when registering in the manifest file in the intent-filter using android:priority = "100" This property to sort, the higher the value of the higher priority.

Since, of course, ordered broadcasts can be truncated. Use Abortbroadcast (); method, when you need to truncate the call on the Ixng, do not invoke the description you do not need to truncate it, he will follow the priority of a one-pass down, know that no one to accept it.


Well, write so much, do not want to use the blog park, with less than a week, really uncomfortable. Looks like it's going to shift.

Detailed broadcast mechanism, broadcast receiver,android advanced Knowledge (ii).

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.