An in-depth understanding of intent in Android

Source: Internet
Author: User

Intent Chinese translation comes from intention, but more reasonably means message-passing device.

How does 1.Intent expire in Android?

As a message transmitter, the first to have the ability to "load" and "unload" the message, in the Android source code, intent actually uses the ordinary message package (Buddle) to load the data.

Code from Android.content.Intent.class

 public intent putextra (String name, charsequence value)  {         if  (mextras == null)  {             mextras = new bundle ();   //It's plain news. Parcel          }         Mextras.putcharsequence (name, value);         return this;// This is a good discovery Oh     }    //add extra data, can be unlimited    public  Intent putextra (String name, bundle value)  {         if  (mextras == null)  {             mextras = new bundle ();         }         mextras.Putbundle (Name, value);        return this;     }        //here is the read section (uninstall)     public  String getstringextra (String name)  {        return  mextras == null ? null : mextras.getstring (name);     }

This only shows the Android data section

2.Intent data transfer is in need of direction, where is the direction?

What needs to be explained here is that the message of intent is broadcast, so the direction is the whole system.


How does 3.Intent find the specified target program?

It can be said that the message is sent out, but in order to find a suitable target, some columns need to be retrieved, these search conditions from action,componet,settype,catagory,packagename

We can often see that when we send a intent, there is not necessarily only one activity or broadcastreceiver or application response, so that's exactly how intent is a broadcast message.


4. Summary

Intent is a message-passing class that sets up and gets messages

Intent will be "broadcast to All Programs" to filter out the appropriate program

Intent is a cross-process, cross-app delivery

Intent carry a search condition









An in-depth understanding of intent in Android

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.