The system provides common Activity programming and activity programming.

Source: Internet
Author: User

The system provides common Activity programming and activity programming.

Common Activity programming provided by the system

// 1. call the phone number // call the mobile customer service at 10086 Uri uri = Uri. parse ("tel: 10086"); Intent intent = new Intent (Intent. ACTION_DIAL, uri); startActivity (intent); // 2. send a text message // send a text message Uri with the content "Hello" to 10086 uri = Uri. parse ("Maid: 10086"); Intent intent = new Intent (Intent. ACTION_SENDTO, uri); intent. putExtra ("sms_body", "Hello"); startActivity (intent); // 3. send MMS (equivalent to sending an SMS with attachments) Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra ("sms_body", "Hello"); Uri uri = Uri. parse ("content: // media/external/images/media/23"); intent. putExtra (Intent. EXTRA_STREAM, uri); intent. setType ("image/png"); startActivity (intent); // 4. open the browser: // open the baidu homepage Uri uri = Uri. parse (" https://www.baidu.com "); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // 5. send an email: (castrated with Google services !!!!) // Send an email Uri uri = Uri to the someone@domain.com. parse ("mailto: someone@domain.com"); Intent intent = new Intent (Intent. ACTION_SENDTO, uri); startActivity (intent); // Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra (Intent. EXTRA_EMAIL, "someone@domain.com"); intent. putExtra (Intent. EXTRA_SUBJECT, "Subject"); intent. putExtra (Intent. EXTRA_TEXT, "Hello"); intent. setType ("text/plain"); startActivity (intent); // send Intent intent = new Intent (Intent. ACTION_SEND); String [] tos = {"1@abc.com", "2@abc.com"}; // recipient String [] ccs = {"3@abc.com", "4@abc.com "}; // CC String [] bccs = {"5@abc.com", "6@abc.com"}; // BCC intent. putExtra (Intent. EXTRA_EMAIL, tos); intent. putExtra (Intent. EXTRA_CC, ccs); intent. putExtra (Intent. EXTRA_BCC, bccs); intent. putExtra (Intent. EXTRA_SUBJECT, "Subject"); intent. putExtra (Intent. EXTRA_TEXT, "Hello"); intent. setType ("message/rfc822"); startActivity (intent); // 6. show map: // open Google map China Beijing location (north latitude 39.9, east longitude 116.3) Uri uri = Uri. parse ("geo: 39.9, 116.3"); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // 7. path Planning // Path 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) Uri uri Uri = Uri. parse (" https://maps.google.com/maps?f=d&saddr=39.9 116.3 & daddr = 31.2 121.4 "); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // 8. multimedia playback: Intent intent = new Intent (Intent. ACTION_VIEW); Uri uri = Uri. parse (" file:///sdcard/foo.mp3 "); Intent. setDataAndType (uri, "audio/mp3"); startActivity (intent); // obtain all audio files under the SD card, and then play the first video =-= Uri uri = Uri. withAppendedPath (MediaStore. audio. media. INTERNAL_CONTENT_URI, "1"); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // 9. enable the camera to take a photo: // enable the camera program Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult (intent, 0); // Bundle extras = intent. getExtras (); Bitmap bitmap = (Bitmap) extras. get ("data"); // another method: // call the System camera application and store the captured image Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); time = Calendar. getInstance (). getTimeInMillis (); intent. putExtra (MediaStore. EXTRA_OUTPUT, Uri. fromFile (new File (Environment. getExternalStorageDirectory (). getAbsolutePath () + "/tucue", time + ". jpg "); startActivityForResult (intent, ACTIVITY_GET_CAMERA_IMAGE); // 10. get and cut the image // get and cut the image Intent intent = new Intent (Intent. ACTION_GET_CONTENT); intent. setType ("image/*"); intent. putExtra ("crop", "true"); // enable intent cut. putExtra ("aspectX", 1); // the aspect ratio of the cut is 1: 2intent. putExtra ("aspectY", 2); intent. putExtra ("outputX", 20); // Save the width and height of the image intent. putExtra ("outputY", 40); intent. putExtra ("output", Uri. fromFile (new File ("/mnt/sdcard/temp"); // Save the path intent. putExtra ("outputFormat", "JPEG"); // return format startActivityForResult (intent, 0); // cut the Intent intent = new Intent ("com. android. camera. action. CROP "); intent. setClassName ("com. android. camera "," com. android. camera. cropImage "); intent. setData (Uri. fromFile (new File ("/mnt/sdcard/temp"); intent. putExtra ("outputX", 1); // the aspect ratio of the cut is 1: 2intent. putExtra ("outputY", 2); intent. putExtra ("aspectX", 20); // Save the width and height of the image intent. putExtra ("aspectY", 40); intent. putExtra ("scale", true); intent. putExtra ("noFaceDetection", true); intent. putExtra ("output", Uri. parse (" file:///mnt/sdcard/temp "); StartActivityForResult (intent, 0); // 11. open Google Market // Open Google Market to go to the detailed page of the program Uri uri = Uri. parse ("market: // details? Id = "+" com. demo. app "); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // 12. go to the mobile phone settings page: // enter the wireless network settings page (you can refer to other settings) Intent intent = new Intent (android. provider. settings. ACTION_WIRELESS_SETTINGS); startActivityForResult (intent, 0); // 13. install apk: Uri installUri = Uri. fromParts ("package", "xxx", null); returnIt = new Intent (Intent. ACTION_PACKAGE_ADDED, installUri); // 14. uninstall apk: Uri uri = Uri. fromParts ("package", strPackageName, null); Intent it = new Intent (Intent. ACTION_DELETE, uri); startActivity (it); // 15. send attachment: Intent it = new Intent (Intent. ACTION_SEND); it. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); it. putExtra (Intent. EXTRA_STREAM ," file:///sdcard/eoe.mp3 "); SendIntent. setType ("audio/mp3"); startActivity (Intent. createChooser (it, "Choose Email Client"); // 16. enter the contact page: Intent intent = new Intent (); intent. setAction (Intent. ACTION_VIEW); intent. setData (People. CONTENT_URI); startActivity (intent); // 17. view the specified contact: Uri personUri = ContentUris. withAppendedId (People. CONTENT_URI, info. id); // info. id contact IDIntent intent = new Intent (); intent. setAction (Intent. ACTION_VIEW); intent. setData (personUri); startActivity (intent );

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.