Android Learning notes--intents and Intent Filters (ii)

Source: Internet
Author: User

I e-mail: [email protected], welcome to exchange discussions.

Welcome reprint, Reprint please specify the website: http://www.cnblogs.com/JohnTsai/p/3993488.html

    • Knowledge Points:

Continue yesterday's intents and Intent filters's study

    • Make up a Intent (Building an Intent):

The Intent object carries information (such as an explicit component name or the type of component (Intent category) that should receive Intent), which the Android system uses

Information determines which component is turned on. It also carries the information that is used by the receiving component in order to fully perform the function.

Intent contains basic information in the following ways:

1. Component Name

 1  //  2  //  The target component's fully restricted class name (fully qualified class name), including the app's package name.   3  //  4  //   We can use the following method to set the component name  5   SetComponent ()  6   SetClass ()  Span style= "color: #008080;" >7   Setclassname ()  8  //  

2. function

1 //2. Functions, Activities (action)2 //specifies a string of functions or activities that are typically performed3 //We can specify the intent action by using the following methods4 5 setaction ()6 //or the intent constructor .7 //if we construct our own action, we have to include the package name of our app as a prefix8 //For example:9    Static FinalString Action_timetravelTen= "Com.johntsai.action.TIMETRAVEL";

3. Data

1 //3. Data2 //uri (URI object) reference data or MIME type data3 //The type of data provided is generally determined by the intent action4 //For example, if the action is action_edit, then data should contain the URI of the editable document5 //Set data URI only6 SetData ()7 //set MIME type only8 SetType ()9 //both are setTen Setdataandtype () One //reminder: If you want to set both 2, you cannot call SetData () and Settype () because they will invalidate the other's values. Setdataandtype () is generally used. 

4. Type

1 // 4. Category (category) 2 // A string that contains additional information about which component should handle intent 3 // a intent can have any number of category descriptions 4 // Specify category 5 addcategory ()

component names, functions, data, types (component name,action,date,category) represent one of the most typical features of a intent,

By reading these properties, the Android system can decide which component to turn on.

5. Additional Parts

1 // 5. Additional parts (Extras) 2 // carry key-value pairs that require additional information to complete the required function (Key-value Paris) 3 // declare our own add-on (our app's intent receive) to ensure that our app package name is included as a prefix 4 // For example: 5 Static Final String Extra_gigawatts = "Com.johntsai.EXTRA_GIGAWATTS";

6. Logo

1 // 6. Flags (flags) 2 // flags instruct the Android system how to open activity (for example, which task the activity belongs to) and how to handle it when it is turned on (for example, whether it belongs to the recent activity list) 3 setflags ();

If you like, please click here to recommend.

To be continued .....

Android Learning notes--intents and Intent Filters (ii)

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.