Android intent + URI application instance

Source: Internet
Author: User
Android intent + URI application instance

1. Install the installer

Uri uri = URI. fromparts ("package", packagename, null); // packagenameindicates the package name, such as com.android123.apk Installer

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

Startactivity (intent );

2. Uninstall uninstall the program

Uri uri = URI. fromparts ("package", packagename, null); // packagenameindicates the package name, such as com.android123.apk Installer

Intent itent = new intent (intent. action_delete, Uri );

Startactivity (intent );

3. Open a webpage

Uri uri = URI. parse ("http://hi.baidu.com/yimifeitian/home ");

Intent intent = new intent (intent. action_view, Uri );

Startactivity (intent );

4. display the location on the map

Uri uri = URI. parse ("Geo: 52.76,-79.0342 ″);

Intent intent = new intent (intent. action_view, Uri );

Startactivity (intent );

5. display the path on the map

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 (intent); // Where startlat, startlng, endlat, endlng are a long with 6 decimals like: 50.123456

6. Call

// Open the dialing Interface

Uri uri = URI. parse ("Tel: 10086 ″);

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

Startactivity (intent );

// Call directly

Uri uri = URI. parse ("Tel: 10086 ″);

Intent intent = new intent (intent. action_call, Uri );

Startactivity (intent );

7. play audio files

Uri uri = URI. parse ("file: // sdcard/download/everything ″);

Intent intent = new intent (intent. action_view, Uri );

Intent. settype ("audio/MP3 ″);

Startactivity (intent );

8. send an email

// Open the mail Interface

Uri uri = URI. parse ("mailto: admin@3gstdy.com ");

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

Startactivity (intent );

// Send the email directly

Intent intent = new intent (intent. action_send );

String [] TOS = {"admin@3gstdy.com "};

String [] CCS = {"webmaster@3gstdy.com "};

Intent. putextra (intent. extra_email, TOS );

Intent. putextra (intent. extra_cc, CCS );

Intent. putextra (intent. extra_text, "I come from http://blog.3gstdy.com ");

Intent. putextra (intent. extra_subject, "http://blog.3gstdy.com"); intent. settype ("Message/rfc882 ″);

Intent. createchooser (intent, "choose email client ");

// Send an email 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/mysong.mp3 ″);

Intent. settype ("audio/MP3 ″);

Startactivity (intent. createchooser (intent, "choose email client "));

9. send text messages

Uri uri = URI. parse ("Tel: 10086 ″);

Intent intent = new intent (intent. action_view, Uri );

Intent. putextra ("sms_body", "I come from http://blog.3gstdy.com ");

Intent. settype ("vnd. Android-DIR/MMS-SMS ");

Startactivity (intent );

10. Send MMS

Uri uri = URI. parse ("content: // media/external/images/Media/23 ″);

Intent intent = new intent (intent. action_send );

Intent. putextra ("sms_body", "3G Android http://blog.3gstdy.com ");

Intent. putextra (intent. extra_stream, Uri );

Intent. settype ("image/PNG ");

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.