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 );
★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