Receive processing for intent:
1. Receiver Registration
This has been introduced before
Then take a look at the remaining two reception functions above. Schedulereceiver Scheduleregisteredreceiver;
Schedulereceiver will fall into the Schedulereceiver function in Activitythread.java, Activitythread.java This is the subject of the target activity, and then the function calls the Handlemessage function in the file, which is called after receiving the receiver message Handlereceiver to handle it. This is an important function. The following is an analysis of the processing of this function:
1. Obtain the component that the intent points to, including the package name, the class name;
2. Get the package information. This structure provides the getClassLoader interface;
3, obtained ClassLoader by java.lang.ClassLoader cl = Packageinfo.getclassloader; 4. Create a receiver dynamically. Receiver = (broadcastreceiver) cl.loadclass (component). newinstance (); 5, call Receiver.onreceive ( Context.getreceiverrestrictedcontext (), data.intent), into the real process of processing; 6, call Finishreceiver to trigger Activitymanagerservice this message to other receivers send or the next broadcast send;
The most important of these is the OnReceive function. We usually implement such a function. And then process the information we received in the inside;
The logic of Scheduleregisteredreceiver
This function is actually done for the way you use dynamic registration. That's how you call the register in your code.
Summarize:
Intent from the point of view of use, is the construction of Intent, providing appropriate parameters, such as action, such as data type. The URI of the data is then sent out; the receiver needs to register a receiver and then provide the OnReceive function. This register can be simply written in the Androidmanifest.xml can also be completed through the Registerreceiver, when the delivery of three APIs can be used: Sendbroadcast sendstickybroadcast Sendorderedbroadcast the first for sending synchronous playback, the other is to send broadcast sticky; the third is for sending serial broadcasts;
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Android Intent Three Solutions