One of Android Intent parsing

Source: Internet
Author: User

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

Related Article

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.