Android Development notes-Uri. parse details

Source: Internet
Author: User
The parse method returns a URI that can be used to access a network or local resource.

1. Tune the web browser
Uri mybloguri = URI. parse ("http://www.baidu.com ");
Returnit = new intent (intent. action_view, mybloguri );
2. Map
Uri mapuri = URI. parse ("Geo: 38.899533,-77.036476 ");
Returnit = new intent (intent. action_view, mapuri );
3. Transfer call interface
Uri teluri = URI. parse ("Tel: 100861 ");
Returnit = new intent (intent. action_dial, teluri );
4. Call directly
Uri calluri = URI. parse ("Tel: 100861 ");
Returnit = new intent (intent. action_call, calluri );
5. Uninstall
Uri uninstalluri = URI. fromparts ("package", "XXX", null );
Returnit = new intent (intent. action_delete, uninstalluri );
6. Install
Uri installuri = URI. fromparts ("package", "XXX", null );
Returnit = new intent (intent. action_package_added, installuri );
7. Play
Uri playuri = URI. parse ("file: // sdcard/download/everything.mp3 ");
Returnit = new intent (intent. action_view, playuri );
8. Call to send an email
Uri emailuri = URI. parse ("mailto: xxxx@gmail.com ");
Returnit = new intent (intent. action_sendto, emailuri );
9. send an email
Returnit = new intent (intent. action_send );
String [] TOS = {"xxxx@gmail.com "};
String [] CCS = {"xxxx@gmail.com "};
Returnit. putextra (intent. extra_email, TOS );
Returnit. putextra (intent. extra_cc, CCS );
Returnit. putextra (intent. extra_text, "body ");
Returnit. putextra (intent. extra_subject, "subject ");
Returnit. settype ("message/rfc882 ");
Intent. createchooser (returnit, "Choose email client ");
10. send text messages
Uri smsuri = URI. parse ("Tel: 100861 ");
Returnit = new intent (intent. action_view, smsuri );
Returnit. putextra ("sms_body", "YYYY ");
Returnit. settype ("Vnd. Android-DIR/MMS-SMS ");
11. send an email directly.
Uri smstouri = URI. parse ("smsto: // 100861 ");
Returnit = new intent (intent. action_sendto, smstouri );
Returnit. putextra ("sms_body", "YYYY ");
12. Send MMS messages
Uri mmsuri = URI. parse ("content: // media/external/images/Media/23 ");
Returnit = new intent (intent. action_send );
Returnit. putextra ("sms_body", "YYYY ");
Returnit. putextra (intent. extra_stream, mmsuri );
Returnit. settype ("image/PNG ");

13. related to market:

1 // Search for an application 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   2 // Display information about an application 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 14. Route Planning Uri uri = URI. parse ("Http://maps.google.com/maps? F = D & saddr = startlat % 20 startlng & daddr = endlat % 20 endlng & HL = EN"); Intent it =New Intent (intent. action_view, Uri ); Startactivity (it ); // Where startlat, startlng, endlat, endlng are a long with 6 decimals like: 50.123456 15. Install the specified APK Public Void Setupapk (string apkname ){ String filename = environment. getexternalstoragedirectory () +"/" + Apkname; Intent intent =New Intent (intent. action_view ); Intent. setdataandtype (URI. fromfile (New File (filename )),"Application/vnd. Android. Package-Archive"); Mservice. startactivity (intent ); } 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 ID Intent intent =New Intent (); Intent. setaction (intent. action_view ); Intent. setdata (personuri ); Startactivity (intent ); 18. Call album Public Static Final String mime_type_image_jpeg ="Image /*"; Public Static Final Int Activity_get_image =0; Intent getimage =New Intent (intent. action_get_content ); Getimage. addcategory (intent. category_openable ); Getimage. settype (mime_type_image_jpeg ); Startactivityforresult (getimage, activity_get_image ); 19. Call the System cameraProgramAnd store photos 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 );

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.