Android development, URI such as: texting, sending MMS, calling contacts, etc.

Source: Internet
Author: User

One, direct calls, and three different is that this direct call, rather than open the dial-up interface



Uri uri = uri.parse ("tel:10086");

Intent Intent = new Intent (Intent.action_call, URI);



Second, open the dial-up interface, type is intent.action_dial



Uri uri = uri.parse ("tel:10086");

Intent Intent = new Intent (intent.action_dial, URI);



Third, open a Web page, the category is Intent.action_view



Uri uri = uri.parse ("http://www.android-study.net/");

Intent Intent = new Intent (Intent.action_view, URI);



Iv. uninstalling an application, the category of intent is intent.action_delete



Uri uri = uri.fromparts ("package", "XXX", null);

Intent Intent = new Intent (Intent.action_delete, URI);



Open the map and navigate to a point



Uri uri = uri.parse ("geo:52.76,-79.0342");

Intent Intent = new Intent (Intent.action_view, URI);



VI. Play audio files



Uri uri = uri.parse ("File:///sdcard/download/everything.mp3");

Intent Intent = new Intent (Intent.action_view, URI);

Intent.settype ("Audio/mp3");



Vii. Install the application, the intent category is intent.action_package_added



Uri uri = uri.fromparts ("package", "XXX", null);

Intent Intent = new Intent (intent.action_package_added, URI);



Eight, open the outgoing mail interface



Uri uri= uri.parse ("Mailto:[email protected]");

Intent Intent = new Intent (intent.action_sendto, URI);



Nine, e-mail, and the last difference here is to send the mail out



Intent Intent = new Intent (intent.action_send);

String[] tos = {"[email protected]" };

String[] CCS = {"[email protected]" };

Intent.putextra (Intent.extra_email, TOS);

Intent.putextra (INTENT.EXTRA_CC, CCS);

Intent.putextra (Intent.extra_text, "I come from Http://www.android-study.net");

Intent.putextra (Intent.extra_subject, "http://www.android-study.net"); Intent.settype ("message/rfc882");

Intent.createchooser (Intent, "Choose Email Client");



Send a message with an attachment



Intent Intent = new Intent (intent.action_send);

Intent.putextra (Intent.extra_subject, "The email SUBJECT text");

Intent.putextra (Intent.extra_stream, "File:///sdcard/mynusic.mp3");

Intent.settype ("Audio/mp3");

StartActivity (Intent.createchooser (Intent, "Choose Email Client"));



Ten, Direct texting



Uri uri= uri.parse ("smsto://100861");

Intent Intent = new Intent (intent.action_sendto, URI);

Intent.putextra ("Sms_body", "Android Send mail Test http://www.android-study.net");



Xi. send MMS



Uri uri= uri.parse ("Content://media/external/images/media/23");

Intent Intent = new Intent (intent.action_send);

Intent.putextra ("Sms_body", "Android Send mail Test http://www.android-study.net");

Intent.putextra (Intent.extra_stream, URI);

Intent.settype ("Image/png");



12. Send SMS



Uri uri= uri.parse ("tel:10086");

Intent Intent = new Intent (Intent.action_view, URI);

Intent.putextra ("Sms_body", "Android Send mail Test http://www.android-study.net");

Intent.settype ("VND. Android-dir/mms-sms ");





13. 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);



14. # Market Related



1//Find an app

Uri uri = uri.parse ("Market://search?q=pname:pkg_name");

Intent it = new Intent (Intent.action_view, URI);

StartActivity (IT);



2//Show information about an app

Uri uri = uri.parse ("market://details?id=app_id");

Intent it = new Intent (Intent.action_view, URI);

StartActivity (IT);





XV, 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), "application/vnd.android.package-archive");

Mservice.startactivity (Intent);

}



16. Path Planning



Uri uri = Uri.parse ("http://maps.google.com/maps?f=d&saddr=startlat%20startlng&daddr=endlat%20endlng& Hl=en ");

Intent it = new Intent (Intent.action_view, URI);

StartActivity (IT);



17. Enter the Contact page



Intent Intent = new Intent ();

Intent.setaction (Intent.action_view);

Intent.setdata (People.content_uri);

StartActivity (Intent);



18. View designated Contacts



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





19. Call the system Camera app and store the captured 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);



20. Call the browser to open the Web page



1. Call the browser to open the Web page



Intent it = new Intent (Intent.action_view, Uri.parse ("http://www.android-study.net"));

It.setclassname ("Com.android.browser", "com.android.browser.BrowserActivity");

StartActivity (IT);



2. Call the browser to open the local Web page



Intent intent=new Intent ();

Intent.setaction ("Android.intent.action.VIEW");

Uri localurl= uri.parse ("content://com.android.htmlfileprovider/sdcard/localweb.html");

Intent.setdata (Localurl);

Intent.setclassname ("Com.android.browser", "com.android.browser.BrowserActivity");

StartActivity (Intent); 

Android development, URI such as: texting, sending MMS, calling contacts, etc.

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.