The architecture of intent consists of three aspects:
Client, which is to send the activity of this intent;
The Server, which is Activitymanagerservice.java, is primarily responsible for distributing these intent to the appropriate objects;
Target, which is the activity that needs to deal with this intent, we call receiver;
The three main aspects of intent: Action, Data, category are also described in previous documents, and are not described here.
Let's go back to the previous example:
Intent Intent = new Intent (Audiomanager.action_audio_becoming_noisy);
Mcontext.sendbroadcast (Intent);
The first sentence is to construct a intent, note that only one parameter is passed, this parameter is an action, no data and category is specified, that is, if a receiver is written like this (in Androidmanifext.xml):
<receiver android:name= "Mediabuttonintentreceiver" >
<intent-filter>
<action android:name= "Android.media.AUDIO_BECOMING_NOISY"/>
</intent-filter> </receiver>
Of course, if you do not like to specify in the. xml, you can also use code to register directly in your application, call Registerreceiver to register your object in the system, the effect is the same.
Thus, once the application has monitored this broadcast message, his Onreceiver function is called.
The purpose of the second sentence is to broadcast the message, this is asynchronous, that is, the broadcast out of nothing, who relations who deal with, and I have no relationship.
Mcontext.sendbroadcast (intent); The Mcontex in this sentence is the application Context, which is a typical binder call, After the call is processed, it goes to Activitymanagernative.java. From then on into another world (running to the end of the service).