Android Study Notes-Intents and Intent Filters (2)

Source: Internet
Author: User

Android Study Notes-Intents and Intent Filters (2)
Knowledge Point: Continue to yesterday's Intents and Intent Filters learning to form an Intent (Building an Intent ): the Intent object carries information (for example, a clear component name or the type of the intent component that should be received). The Android system uses this information to determine which component to enable. It also carries the information used by the received components for full functionality execution. Intent contains the following basic information: 1. component Name copy code 1 // 1. component name 2 // full restricted class name (fully qualified class name) of the target Component, including the package name of the app. 3 // For example, com. johntsai. secondActivity4 // we can use the following method to set the component name 5 setComponent () 6 setClass () 7 setClassName () 8 // or the Intent constructor to copy Code 2. function copy code 1 // 2. function, Activity 2 // specifies the function or activity string to be executed. 3 // you can specify the Intent Action by using the following method: 4 5 setAction () 6 // or Intent constructor 7 // if we construct our own action, we must include the package name of our app as the prefix 8 // For example: 9 static final String ACTION_TIMETRAVEL 10 = "com. johntsai. action. TIMETRAVEL "; copy code 3. data Replication code 1 // 3. data 2 // URI (Uri object) Reference data or MIME-type data 3 // the data type provided is generally determined by the intent action 4 // For example, the action is ACTION_EDIT, data should contain the Editable document URI 5 // only set data URI 6 setData () 7 // only set the MIME type 8 setType () 9 // set both 10 setDataAndType () 11 // reminder: If you want to set both 2, you cannot call setData () or setType () because they will invalidate the values of the other party. SetDataAndType () is generally used (). Copy code 4. type 1 // 4. category 2 // string containing the additional information about which component should process Intent 3 // A intent can have any number of category descriptions 4 // specify category5 addCategory () the component name, function, data, and type (component name, action, date, and category) represent the most typical features of an Intent. By reading these attributes, the Android system can decide which component to enable. 5. additional Part 1 // 5. extras 2 // Key-value paris) 3 // declare our own additional parts (Intent reception of our app) to ensure that our app package name is included as the prefix 4 // For example: 5 static final String EXTRA_GIGAWATTS = "com. johntsai. EXTRA_GIGAWATTS "; 6. mark 1 // 6. flag (Flags) 2 // Flags guides Android system on how to enable Activity (for example, which task the Activity belongs to) and how to process it after it is enabled (for example, whether it belongs to the latest Activity list) 3 setFlags ();

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.