1. Search for content from google
Intent intent = new Intent ();
Intent. setAction (Intent. ACTION_WEB_SEARCH );
Intent. putExtra (SearchManager. QUERY, "searchString ")
StartActivity (intent );
2. Browse the webpage
Uri uri = Uri. parse ("http://www.google.com ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (it );
3. display a map
Uri uri = Uri. parse ("geo: 38.899533,-77.036476 ");
Intent it = newIntent (Intent. Action_VIEW, uri );
StartActivity (it );
4. Route Planning
Uri uri = Uri. parse ("http://maps.google.com/maps? F = dsaddr = startLat % 20 startLng & daddr = endLat % 20 endLng & hl = en ");
Intent it = newIntent (Intent. ACTION_VIEW, URI );
StartActivity (it );
5. Call
Uri uri = Uri. parse ("tel: xxxxxx ");
Intent it = new Intent (Intent. ACTION_DIAL, uri );
StartActivity (it );
6. Call the SMS Program
Method 1:
Intent it = newIntent (Intent. ACTION_VIEW );
It. putExtra ("sms_body", "TheSMS text ");
It. setType ("vnd. android-dir/mms-sms ");
StartActivity (it );
7. send SMS
Method 2:
Uri uri = Uri. parse ("smsto: 0800000123 ");
Intent it = newIntent (Intent. ACTION_SENDTO, uri );
It. putExtra ("sms_body", "TheSMS text ");
StartActivity (it );
Method 3:
String body = "this is sms demo ";
Intent mmsintent = newIntent (Intent. ACTION_SENDTO, Uri. fromParts ("smsto", number, null ));
Mmsintent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_BODY, body );
Mmsintent. putExtra (Messaging. KEY_ACTION_SENDTO_COMPOSE_MODE, true );
Mmsintent. putExtra (Messaging. KEY_ACTION_SENDTO_EXIT_ON_SENT, true );
StartActivity (mmsintent );
8. Send MMS
Uri uri = Uri. parse ("content: // media/external/images/media/23 ");
Intent it = newIntent (Intent. ACTION_SEND );
It. putExtra ("sms_body", "some text ");
It. putExtra (Intent. EXTRA_STREAM, uri );
It. setType ("image/png ");
StartActivity (it );
StringBuilder sb = new StringBuilder ();
Sb. append ("file ://");
Sb. append (fd. getAbsoluteFile ());
Intent intent = newIntent (Intent. ACTION_SENDTO, Uri. fromParts ("mmsto", number, null ));
// Below extra datas are all optional.
Intent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject );
Intent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_BODY, body );
Intent. putExtra (Messaging. KEY_ACTION_SENDTO_CONTENT_URI, sb. toString ());
Intent. putExtra (Messaging. KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode );
Intent. putExtra (Messaging. KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent );
StartActivity (intent );
9. Send Email
Uri uri = Uri. parse ("mailto: xxx@abc.com ");
Intent it = newIntent (Intent. ACTION_SENDTO, uri );
StartActivity (it );
Intent it = new Intent (Intent. ACTION_SEND );
It. putExtra (Intent. EXTRA_EMAIL, "me@abc.com ");
It. putExtra (Intent. EXTRA_TEXT, "Theemail body text ");
It. setType ("text/plain ");
StartActivity (Intent. createChooser (it, "Choose Email Client "));
Intent it = new Intent (Intent. ACTION_SEND );
String [] tos = {"me@abc.com "};
String [] ccs = {"you@abc.com "};
It. putExtra (Intent. EXTRA_EMAIL, tos );
It. putExtra (Intent. EXTRA_CC, ccs );
It. putExtra (Intent. EXTRA_TEXT, "Theemail body text ");
It. putExtra (Intent. EXTRA_SUBJECT, "Theemail subject text ");
It. setType ("message/rfc822 ");
StartActivity (Intent. createChooser (it, "Choose Email Client "));
Intent it = newIntent (Intent. ACTION_SEND );
It. putExtra (Intent. EXTRA_SUBJECT, "Theemail subject text ");
It. putExtra (Intent. EXTRA_STREAM, "file: // sdcard/mysong.mp3 ");
SendIntent. setType ("audio/mp3 ");
StartActivity (Intent. createChooser (it, "Choose Email Client "));
10. Play multimedia
Intent it = new Intent (Intent. ACTION_VIEW );
Uri uri = Uri. parse ("file: // sdcard/song.mp3 ");
It. setDataAndType (uri, "audio/mp3 ");
StartActivity (it );
Uri uri = Uri. withAppendedPath (MediaStore. Audio. Media. INTERNAL_CONTENT_URI, "1 ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (it );
11. uninstall apk
Uri uri = Uri. fromParts ("package", strPackageName, null );
Intent it = newIntent (Intent. ACTION_DELETE, uri );
StartActivity (it );
12. install apk
Uri installUri = Uri. fromParts ("package", "xxx", null );
ReturnIt = newIntent (Intent. ACTION_PACKAGE_ADDED, installUri );
Intent intent = new Intent (Intent. ACTION_VIEW );
Intent. setDataAndType (Uri. parse ("file: //" + filepath), "application/vnd. android. package-archive ");
StartActivity (intent); // install
13. Open the camera
<1> Intent intent = new Intent ("android. media. action. STILL_IMAGE_CAMERA"); // call the camera
StartActivity (intent );
<2> Intent I = new Intent (Intent. ACTION_CAMERA_BUTTON, null );
This. sendBroadcast (I );
<3> long dateTaken = System. currentTimeMillis ();
String name = createName (dateTaken) + ". jpg ";
FileName = folder + name;
ContentValues values = new ContentValues ();
Values. put (Images. Media. TITLE, fileName );
Values. put ("_ data", fileName );
Values. put (Images. Media. PICASA_ID, fileName );
Values. put (Images. Media. DISPLAY_NAME, fileName );
Values. put (Images. Media. DESCRIPTION, fileName );
Values. put (Images. ImageColumns. BUCKET_DISPLAY_NAME, fileName );
Uri photoUri = getContentResolver (). insert (
MediaStore. Images. Media. EXTERNAL_CONTENT_URI, values );
Intent inttPhoto = new Intent (MediaStore. ACTION_IMAGE_CAPTURE );
InttPhoto. putExtra (MediaStore. EXTRA_OUTPUT, photoUri );
StartActivityForResult (inttPhoto, 10 );
14. Select an image from gallery
Intent I = new Intent ();
I. setType ("image /*");
I. setAction (Intent. ACTION_GET_CONTENT );
StartActivityForResult (I, 11 );
15. Enable the recorder
Intent mi = new Intent (Media. RECORD_SOUND_ACTION );
StartActivity (mi );
16. display the detailed list of applications
Uri uri = Uri. parse ("market: // details? Id = app_id ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (it );
// Where app_id is the application ID, findthe ID
// By clicking on your application on Markethome
// Page, and notice the ID from the addressbar
Failed to find the app id just now. It turns out that the package name can also be used.
Uri uri = Uri. parse ("market: // details? Id = <packagename> ");
This is much simpler.
17. Search for Applications
Uri uri = Uri. parse ("market: // search? Q = pname: pkg_name ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (it );
// Where pkg_name is the full package pathfor an application
18 open the contact list
<1>
Intent I = new Intent ();
I. setAction (Intent. ACTION_GET_CONTENT );
I. setType ("vnd. android. cursor. item/phone ");
StartActivityForResult (I, REQUEST_TEXT );
<2>
Uri uri = Uri. parse ("content: // contacts/people ");
Intent it = new Intent (Intent. ACTION_PICK, uri );
StartActivityForResult (it, REQUEST_TEXT );
19 open another program
Intent I = new Intent ();
ComponentName cn = newComponentName ("com. yellowbook. android2 ",
"Com. yellowbook. android2.AndroidSearch ");
I. setComponent (cn );
I. setAction ("android. intent. action. MAIN ");
StartActivityForResult (I, RESULT_ OK );
20. Call the system editor to add a contact (for later SDK versions ):
Intent it = newIntent (Intent. ACTION_INSERT_OR_EDIT );
It. setType ("vnd. android. cursor. item/contact ");
// It. setType (Contacts. CONTENT_ITEM_TYPE );
It. putExtra ("name", "myName ");
It. putExtra (android. provider. Contacts. Intents. Insert. COMPANY, "organization ");
It. putExtra (android. provider. Contacts. Intents. Insert. EMAIL, "email ");
It. putExtra (android. provider. Contacts. Intents. Insert. PHONE, "homePhone ");
It. putExtra (android. provider. Contacts. Intents. Insert. SECONDARY_PHONE,
"MobilePhone ");
It. putExtra (android. provider. Contacts. Intents. Insert. TERTIARY_PHONE,
"WorkPhone ");
It. putExtra (android. provider. Contacts. Intents. Insert. JOB_TITLE, "title ");
StartActivity (it );
21. Call the system editor to add a contact (all valid ):
Intent intent = newIntent (Intent. ACTION_INSERT_OR_EDIT );
Intent. setType (People. CONTENT_ITEM_TYPE );
Intent. putExtra (Contacts. Intents. Insert. NAME, "My Name ");
Intent. putExtra (Contacts. Intents. Insert. PHONE, "+ 1234567890 ");
Intent. putExtra (Contacts. Intents. Insert. PHONE_TYPE, Contacts. PhonesColumns. TYPE_MOBILE );
Intent. putExtra (Contacts. Intents. Insert. EMAIL, "com@com.com ");
Intent. putExtra (Contacts. Intents. Insert. EMAIL_TYPE, Contacts. ContactMethodsColumns. TYPE_WORK );
StartActivity (intent );
Sdk documentation android_sdk/docs/guide/appendix/g-app-intents.html
★Intent action Daquan:
Android. intent. action. ALL_APPS
Android. intent. action. ANSWER
Android. intent. action. ATTACH_DATA
Android. intent. action. BUG_REPORT
Android. intent. action. CALL
Android. intent. action. CALL_BUTTON
Android. intent. action. CHOOSER
Android. intent. action. CREATE_LIVE_FOLDER
Android. intent. action. CREATE_SHORTCUT
Android. intent. action. DELETE
Android. intent. action. DIAL
Android. intent. action. EDIT
Android. intent. action. GET_CONTENT
Android. intent. action. INSERT
Android. intent. action. INSERT_OR_EDIT
Android. intent. action. MAIN
Android. intent. action. MEDIA_SEARCH
Android. intent. action. PICK
Android. intent. action. PICK_ACTIVITY
Android. intent. action. RINGTONE_PICKER
Android. intent. action. RUN
Android. intent. action. SEARCH
Android. intent. action. SEARCH_LONG_PRESS
Android. intent. action. SEND
Android. intent. action. SENDTO
Android. intent. action. SET_WALLPAPER
Android. intent. action. SYNC
Android. intent. action. SYSTEM_TUTORIAL
Android. intent. action. VIEW
Android. intent. action. VOICE_COMMAND
Android. intent. action. WEB_SEARCH
Android.net. wifi. PICK_WIFI_NETWORK
Android. settings. AIRPLANE_MODE_SETTINGS
Android. settings. APN_SETTINGS
Android. settings. APPLICATION_DEVELOPMENT_SETTINGS
Android. settings. APPLICATION_SETTINGS
Android. settings. effecth_settings
Android. settings. DATA_ROAMING_SETTINGS
Android. settings. DATE_SETTINGS
Android. settings. DISPLAY_SETTINGS
Android. settings. INPUT_METHOD_SETTINGS
Android. settings. INTERNAL_STORAGE_SETTINGS
Android. settings. LOCALE_SETTINGS
Android. settings. LOCATION_SOURCE_SETTINGS
Android. settings. MANAGE_APPLICATIONS_SETTINGS
Android. settings. MEMORY_CARD_SETTINGS
Android. settings. NETWORK_OPERATOR_SETTINGS
Android. settings. QUICK_LAUNCH_SETTINGS
Android. settings. SECURITY_SETTINGS
Android. settings. SETTINGS
Android. settings. SOUND_SETTINGS
Android. settings. SYNC_SETTINGS
Android. settings. USER_DICTIONARY_SETTINGS
Android. settings. WIFI_IP_SETTINGS
Android. settings. WIFI_SETTINGS
Android. settings. WIRELESS_SETTINGS