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).