Android Intent Analysis of the third

Source: Internet
Author: User

Intent the receiving process:

1. Receiver Registration
I've already introduced this before.
Next take a look at the above two receive function, Schedulereceiver scheduleregisteredreceiver;

Schedulereceiver will fall into the Schedulereceiver function in Activitythread.java, Activitythread.java This is the subject of the target activity, then the function calls to the Handlemessage function in the file, which is called after receiving the receiver message Handlereceiver to deal with, this is an important function, the following analysis of a The processing of this function:
1, get this intent point to the component, including the package name, class name;
2, obtain the package information, this structure provides the getClassLoader interface;

3, by Java.lang.ClassLoader cl = Packageinfo.getclassloader get ClassLoader; 4, dynamically create a receiver,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, which we usually implement and then process the messages we receive.
The logic of Scheduleregisteredreceiver
This function is actually for the way you use dynamic registration, which is how you invoke register registration in the code.

Summarize:

Intent from the point of view of use, is constructs the Intent, provides the appropriate parameters, such as the action, such as the data type, the data URI and so on, then sends out, the receiver needs to register a receiver, then provides the OnReceive function to be possible This registration can be simply written in the Androidmanifest.xml can also be done through the registerreceiver, when sent there are three APIs can be used: Sendbroadcast sendstickybroadcast Sendorderedbroadcast first for sending parallel broadcasts, the second for sending sticky broadcasts, and the third for sending serial broadcasts;

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.