In-depth analysis of Android application fields

Source: Internet
Author: User

Every Android application may run in its own process and has an independent Dalvik Virtual Machine instance. Android is a large system with hundreds of megabytes of data, each part has an organic relationship and is only available for everyone to learn and think about.

Intent describes the actions, actions involving data, and additional data of an application. Android identifies the corresponding components based on the description of the Intent, pass Intent to the called component and complete the call of the component. Therefore, Intent acts as a media intermediary here, providing information about component calls to each other to decouple callers from callers.

For example, in an application maintained by a contact, when we assume the corresponding Activity is listActivity on the screen of a contact list, click a contact, you want to jump out of the contact's details page and assume that the corresponding Activity is detailActivity)

To achieve this purpose, listActivity needs to construct an Intent, which is used to tell the system that we want to perform the "View" action. The corresponding viewing object of this action is "a contact ", call startActivity (Intent intent ),

The constructed Intent is passed in. The system will find the Activity that meets the Intent requirements in ManiFest according to the description in this Intent. The system will call the Activity that is found, that is, detailActivity, and finally pass in the Intent, detailActivity performs the corresponding operation based on the description in the Intent.

In the Android reference document, Intent is defined as an abstract description of an operation ). Let's take a look at the abstract description. First, it is a brief description of the action to be executed, such as VIEW_ACTION view) and EDIT_ACTION modification. Android defines a set of standard actions for us:

 
 
  1. MAIN_ACTION  
  2. VIEW_ACTION  
  3. EDIT_ACTION  
  4. PICK_ACTION  
  5. GET_CONTENT_ACTION  
  6. DIAL_ACTION  
  7. CALL_ACTION  
  8. SENDTO_ACTION  
  9. ANSWER_ACTION  
  10. INSERT_ACTION  
  11. DELETE_ACTION  
  12. RUN_ACTION  
  13. LOGIN_ACTION  
  14. CLEAR_CREDENTIALS_ACTION  
  15. SYNC_ACTION  
  16. PICK_ACTIVITY_ACTION  
  17. WEB_SEARCH_ACTION  

In addition, we can also define our own actions based on the needs of the application, and define the corresponding Android Application to process our custom actions. Secondly, is the data to be operated by the action ). Android uses a URI pointing to data. For example, in a contact application, a URI pointing to a contact may be:

 
 
  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  2.        package="com.android.notepad  
  3. "> 
  4.      <application android:icon="@drawable/app_notes" 
  5.              android:label="@string/app_name"> 
  6.  
  7.          <provider class=".NotePadProvider" 
  8.                  android:authorities="com.google.provider.NotePad  
  9. /> 
  10.  
  11.          <activity class=".NotesList" android:label="@string/title_notes_list"> 
  12.              <intent-filter> 
  13.                  <action android:value="android.intent.action.MAIN" /> 
  14.                  <category android:value="android.intent.category.LAUNCHER" /> 
  15.              </intent-filter> 
  16.              <intent-filter> 
  17.                  <action android:value="android.intent.action.VIEW" /> 
  18.                  <action android:value="android.intent.action.EDIT" /> 
  19.                  <action android:value="android.intent.action.PICK" /> 
  20.                  <category android:value="android.intent.category.DEFAULT" /> 
  21.                  <type android:value="vnd.android.cursor.dir/vnd.google.note  
  22. /> 

Android app, additional information of the executed action. For example, LAUNCHER_CATEGORY indicates that the receiver of Intent should appear as a top-level application in Launcher, while ALTERNATIVE_CATEGORY indicates that the current Intent is one of a series of optional actions that can be executed on the same piece of data.

Type), explicitly specify the Intent data type MIME ). Generally, the Intent data type can be determined based on the data itself. However, by setting this attribute, You can forcibly use the explicitly specified type instead of derivation.

Specifies the Class Name of the Intent's target component. Generally, Android searches for other attributes in Intent, such as action, data/type, and category. Finally, find a matched target component. However, if this attribute of component is specified, the component specified by component will be used directly without executing the above search process. After this attribute is specified, all other Intent attributes are optional.

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.