Android intent and intent action Overview

Source: Internet
Author: User

Android intent and intent action Overview
Intent is frequently used in android. Intent is used for system functions, whether it is page redirection, data transmission, or external program calling. After some intent examples, I sorted out the intent and hoped it would be useful to everyone. Because there are too many intent content, it is impossible to write it completely, and it will inevitably be left blank. I will update it at any time in the future. If you have any questions or new intent content, please contact us.
★Intent Daquan:
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 = new Intent (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 = new Intent (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
Intent it = new Intent (Intent. ACTION_VIEW );
It. putExtra ("sms_body", "The SMS text ");
It. setType ("vnd. android-dir/mms-sms ");
StartActivity (it );

7. send SMS
Uri uri = Uri. parse ("smsto: 0800000123 ");
Intent it = new Intent (Intent. ACTION_SENDTO, uri );
It. putExtra ("sms_body", "The SMS text ");
StartActivity (it );
String body = "this is sms demo ";
Intent mmsintent = new Intent (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 = new Intent (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 = new Intent (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 = new Intent (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, "The email 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, "The email body text ");
It. putExtra (Intent. EXTRA_SUBJECT, "The email subject text ");
It. setType ("message/rfc822 ");
StartActivity (Intent. createChooser (it, "Choose Email Client "));

Intent it = new Intent (Intent. ACTION_SEND );
It. putExtra (Intent. EXTRA_SUBJECT, "The email 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 = new Intent (Intent. ACTION_DELETE, uri );
StartActivity (it );

12. install apk
Uri installUri = Uri. fromParts ("package", "xxx", null );
ReturnIt = new Intent (Intent. ACTION_PACKAGE_ADDED, installUri );

13. Open the camera
<1> Intent I = new Intent (Intent. ACTION_CAMERA_BUTTON, null );
This. sendBroadcast (I );
<2> 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, find the ID
// By clicking on your application on Market home
// Page, and notice the ID from the address bar

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 path for 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 = new ComponentName ("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 = new Intent (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 = new Intent (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 );

22 (updated)
// Directly call out
Uri uri = Uri. parse ("tel: 0800000123 ");
Intent it = new Intent (Intent. ACTION_CALL, uri );
StartActivity (it );
// Add this parameter to AndroidManifest. xml
// <Uses-permission id = "android. permission. CALL_PHONE"/>

23. intent of the most basic share information. You can transmit a text message to the installed apps on various mobile phones, such as SMS, Email, sina, mi chat, facebook, twitter, etc.

Intent it = new Intent (Intent. ACTION_SEND );
It. putExtra (Intent. EXTRA_TEXT, "The email subject text ");
It. setType ("text/plain ");
StartActivity (Intent. createChooser (it, "Choose Email Client "));

24. Call the intent of skype

Method 1: the old version is unavailable in the new version, probably because the skype activity structure changes:

// Intent sky = new Intent ("android. intent. action. CALL_PRIVILEGED ");
// Sky. setClassName ("com. skype. raider ",
// "Com. skype. raider. contactsync. ContactSkypeOutCallStartActivity ");
// Sky. setData (Uri. parse ("tel:" + phone ));
// StartActivity (sky );

Method 2: Open the main page of skype:

// PackageManager packageManager = getActivity (). getPackageManager ();
// Intent skype = packageManager. getLaunchIntentForPackage ("com. skype. raider ");
// Skype. setData (Uri. parse ("tel: 65465446 "));
// StartActivity (skype );

Method 3: Enter the phone number, directly go to the skype dialing screen, and call:

Intent intent = new Intent ("android. intent. action. CALL_PRIVILEGED ");
Intent. setClassName ("com. skype. raider ",
"Com. skype. raider. Main ");
Intent. setData (Uri. parse ("tel:" + phone ));
StartActivity (intent );

★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

 

 

 

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.