1 displaying contact information based on contact ID
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view); //Show contact information
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
2 Display dial-up panel based on contact ID
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_dial); //Display dial-up panel
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
3 Display the dialer panel and display the number on the Dial panel
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view);
- Intent.setdata (Uri.parse ("tel://15216448315"));
- StartActivity (Intent);
4 Display the dialer panel and display the number on the Dial panel
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_dial); //Display the dialer panel and display the number on the Dial panel
- Intent.setdata (Uri.parse ("tel://15216448315"));
- StartActivity (Intent);
5 Edit contacts based on the ID of the contact person
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_edit); //Edit Contacts
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
6 displays a list of contacts and other account contacts for the contact person
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view);
- Intent.setdata (Uri.parse ("content://contacts/people/"));
- StartActivity (Intent);
7 Start homescreen
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_main); //Start homescreen
- Intent.addcategory (Intent.category_home);
- StartActivity (Intent);
8 Select a contact's number and return a URI that represents this number, such as: content://contacts/phones/982
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_get_content);
- Intent.settype ("Vnd.android.cursor.item/phone");
- Startactivityforresult (Intent, 1);
9 Open multiple Apps Select various types of data to return as URIs. The returned URI can be opened using Contentresolver.openinputstream (URI)
This feature can be used to select attachments in a message
Examples are as follows:
Select a picture and return the URI as CONTENT://MEDIA/EXTERNAL/IMAGES/MEDIA/47
Choose a song that returns a URI of CONTENT://MEDIA/EXTERNAL/AUDIO/MEDIA/51
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_get_content);
- Intent.settype ("*/*");
- Intent.addcategory (intent.category_openable);
- Startactivityforresult (Intent, 2);
10 Customizing a Chooser, not using the system's Chooser
The chooser can have its own caption (title)
And you don't have to specify preferences
[Java]View PlainCopy
- intent intent = new Intent ();
- intent.setaction (intent.action_chooser);
- intent.putextra (Intent.extra_title, "My chooser");
- Intent.putextra (intent.extra_intent,
- new intent (intent.action_get_content)
- .settype ( "*/*")
- .addcategory (Intent.CATEGORY _openable)
- );
-   
- Startactivityforresult (Intent, 2);
11 Select activity, the returned activity can be obtained in the Returned Intent.getcomponent ()
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_pick_activity);
- Intent.putextra (Intent.extra_intent,
- new Intent (intent.action_get_content)
- . SetType ("*/*")
- . Addcategory (Intent.category_openable)
- );
- Startactivityforresult (Intent, 3);
12 Start the search, in the following sample code, "ANDROID" is the string to search for
When this code is executed, a list of programs that can be used for searching is displayed in the system's Chooser
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_search); //Start Search
- Intent.putextra (Searchmanager.query, "ANDROID");
- StartActivity (Intent);
13 Start web Search, in the following sample code, "ANDROID" is the string to search for
When this code is executed, a list of programs that can be used for searching is displayed in the system's chooser, and in general the browsers installed in the system will be displayed
[Java]View PlainCopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_web_search); //Start Search
- Intent.putextra (Searchmanager.query, "ANDROID");
- StartActivity (Intent);
Standard intent for activity in Android systems