Android Intent usage Summary

Source: Internet
Author: User
[Code] Call the dialing program 1 // call mobile customer service 10086 2Uri uri = Uri. parse ("tel: 10086"); 3 Intent intent = new Intent (Intent. ACTION_DIAL, uri); 4 startActivity (intent); [Code] send SMS or MMS view sourceprint? 01 // send "Hello" text message 02Uri uri = Uri to 10086. parse ("smsto: 10086"); 03 Intent intent = new Intent (Intent. ACTION_SENDTO, uri); 04intent. putExtra ("sms_body", "Hello"); 05 startActivity (intent); 06 // send MMS (equivalent to sending SMS messages with attachments) 07 Intent intent = new Intent (Intent. ACTION_SEND); 08intent. putExtra ("sms_body", "Hello"); 09Uri uri = Uri. parse ("content: // media/external/images/media/23"); 10intent. putExtra (Intent. EXTRA_STREAM, uri); 11intent. setType ("image/png"); 12 startActivity (intent); [Code] Open the webpage through a browser 1 // open the Google homepage 2Uri uri = Uri. parse ("http://www.google.com"); 3 Intent intent = new Intent (Intent. ACTION_VIEW, uri); 4 startActivity (intent); [Code] Send email 01 // send an email to the someone@domain.com 02Uri uri Uri = uri. parse ("mailto: someone@domain.com"); 03 Intent intent = new Intent (Intent. ACTION_SENDTO, uri); 04 startActivity (intent); 05 // mail the someone@domain.com The email sent with the content "Hello" 06 Intent intent = new Intent (Intent. ACTION_SEND); 07intent. putExtra (Intent. EXTRA_EMAIL, "someone@domain.com"); 08intent. putExtra (Intent. EXTRA_SUBJECT, "Subject"); 09intent. putExtra (Intent. EXTRA_TEXT, "Hello"); 10intent. setType ("text/plain"); 11 startActivity (intent); 12 // send an email to multiple users 13 Intent intent = new Intent (Intent. ACTION_SEND); 14 String [] tos = {"1@abc.com", "2@abc.com"}; // recipient 15 String [] ccs = {"3@abc.com", "4@abc.com"}; // CC 16 String [] bccs = {"5@abc.com", "6@abc.com"}; // BCC 17intent. putExtra (Intent. EXTRA_EMAIL, tos); 18intent. putExtra (Intent. EXTRA_CC, ccs); 19intent. putExtra (Intent. EXTRA_BCC, bccs); 20intent. putExtra (Intent. EXTRA_SUBJECT, "Subject"); 21intent. putExtra (Intent. EXTRA_TEXT, "Hello"); 22intent. setType ("message/rfc822"); 23 startActivity (intent); [Code] display map and Path Planning 1 // open Google map Beijing, China Location (latitude 39.9, longitude 116.3) 2Uri uri = Uri. parse ("geo: 39.9, 116.3"); 3 Intent intent = new Intent (Intent. ACTION_VIEW, uri); 4 startActivity (intent); 5 // Route Planning: from a certain place in Beijing (latitude 39.9, longitude 116.3) to a certain place in Shanghai (latitude 31.2, longitude 121.4) 6Uri uri = Uri. parse ("http://maps.google.com/maps? F = d & saddr = 39.9 116.3 & daddr = 31.2 121.4 "); 7 Intent intent = new Intent (Intent. ACTION_VIEW, uri); 8 startActivity (intent); [Code] Play multimedia 1 Intent intent = new Intent (Intent. ACTION_VIEW); 2Uri uri = Uri. parse ("file: // sdcard/foother"); 3intent. setDataAndType (uri, "audio/mp3"); 4 startActivity (intent); 5 6Uri uri = Uri. withAppendedPath (MediaStore. audio. media. INTERNAL_CONTENT_URI, "1"); 7 Intent intent = new Intent (Inte Nt. ACTION_VIEW, uri); 8 startActivity (intent); [Code] photo 1 // open the camera program 2 Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); 3 startActivityForResult (intent, 0); 4 // retrieve photo data 5 Bundle extras = intent. getExtras (); 6 Bitmap bitmap = (Bitmap) extras. get ("data"); [Code] get and cut the image 01 // get and cut the image 02 Intent intent = new Intent (Intent. ACTION_GET_CONTENT); 03intent. setType ("image/*"); 04intent. putExtra ("crop", "true"); // enable cut 05 Intent. putExtra ("aspectX", 1); // the aspect ratio of the cut is 1: 206intent. putExtra ("aspectY", 2); 07intent. putExtra ("outputX", 20); // Save the width and height of the image to 08intent. putExtra ("outputY", 40); 09intent. putExtra ("output", Uri. fromFile (new File ("/mnt/sdcard/temp"); // Save the 10intent path. putExtra ("outputFormat", "JPEG"); // return Format 11 startActivityForResult (intent, 0); 12 // cut a specific image 13 Intent intent = new Intent ("com. android. camera. action. CROP "); 14 inten T. setClassName ("com. android. camera "," com. android. camera. cropImage "); 15intent. setData (Uri. fromFile (new File ("/mnt/sdcard/temp"); 16intent. putExtra ("outputX", 1); // the aspect ratio of the cut is 1: 217intent. putExtra ("outputY", 2); 18intent. putExtra ("aspectX", 20); // Save the width and height of the image. putExtra ("aspectY", 40); 20intent. putExtra ("scale", true); 21intent. putExtra ("noFaceDetection", true); 22intent. putExtra ("output", Uri. parse ("File: // mnt/sdcard/temp"); 23 startActivityForResult (intent, 0 ); [Code] Open Google Market1 // Open Google Market and directly go to the detailed page of the program 2Uri uri = Uri. parse ("market: // details? Id = "+" com. demo. app "); 3 Intent intent = new Intent (Intent. ACTION_VIEW, uri); 4 startActivity (intent); [Code] install and uninstall programs 1Uri uri = Uri. fromParts ("package", "com. demo. app ", null); 2 Intent intent = new Intent (Intent. ACTION_DELETE, uri); 3 startActivity (intent); [Code] Go to the settings page. 1 // enter the wireless network settings page (other options can be used to show the opposite) 2 Intent intent = new Intent (android. provider. settings. ACTION_WIRELESS_SETTINGS); 3 startActivityForResult (intent, 0 );
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.