Common URI & intent settings for Android call system components

Source: Internet
Author: User

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

Enter the contact page
1. Intent intent = new intent ();
2. Intent. setaction (intent. action_view );
3. Intent. setdata (people. content_uri );
4. startactivity (intent );

View specified contacts
1. Uri personuri = contenturis. withappendedid (people. content_uri, info. ID); // info. Id contact ID
2. Intent intent = new intent ();
3. Intent. setaction (intent. action_view );
4. Intent. setdata (personuri );
5. startactivity (intent );
Display webpage:

1. Uri uri = URI. parse (http://www.google.com ");
2. Intent it = new intent (intent. action_view, Uri );
3. startactivity (it );

Display map:

1. Uri uri = URI. parse ("Geo: 38.899533,-77.036476 ″);
2. Intent it = new intent (intent. action_view, Uri );
3. startactivity (it );

Path Planning:

1. Uri uri = URI. parse ("http://maps.google.com/maps? F = D & saddr = startlat % 20 startlng & daddr = endlat % 20 endlng & HL = EN ");
2. Intent it = new intent (intent. action_view, Uri );
3. startactivity (it );

Call number:
Call the dialup Program

1. Uri uri = URI. parse ("Tel: xxxxxx ");
2. Intent it = new intent (intent. action_dial, Uri );
3. startactivity (it );

1. Uri uri = URI. parse ("Tel. xxxxxx ");
2. Intent it = new intent (intent. action_call, Uri );
3. To use this function, you must add <uses-Permission id = "android. Permission. call_phone"/> to the configuration file.

Send SMS/MMS
Call the program for sending text messages

1. Intent it = new intent (intent. action_view );
2. it. putextra ("sms_body", "the SMS text ");
3. It. settype ("Vnd. Android-DIR/MMS-SMS ");
4. startactivity (it );

Send SMS

1. Uri uri = URI. parse ("smsto: 0800000123 ″);
2. Intent it = new intent (intent. action_sendto, Uri );
3. It. putextra ("sms_body", "the SMS text ");
4. startactivity (it );

Send MMS

1. Uri uri = URI. parse ("content: // media/external/images/Media/23 ″);
2. Intent it = new intent (intent. action_send );
3. It. putextra ("sms_body", "some text ");
4. It. putextra (intent. extra_stream, Uri );
5. It. settype ("image/PNG ");
6. startactivity (it );

Send email

1. Uri uri = URI. parse ("mailto: xxx@abc.com ");
2. Intent it = new intent (intent. action_sendto, Uri );
3. startactivity (it );

1. Intent it = new intent (intent. action_send );
2. it. putextra (intent. extra_email, "me@abc.com ");
3. It. putextra (intent. extra_text, "the email body text ");
4. It. settype ("text/plain ");
5. startactivity (intent. createchooser (it, "choose email client "));

1. Intent it = new intent (intent. action_send );
2. String [] TOS = {"me@abc.com "};
3. String [] CCS = {"you@abc.com "};
4. It. putextra (intent. extra_email, TOS );
5. It. putextra (intent. extra_cc, CCS );
6. It. putextra (intent. extra_text, "the email body text ");
7. It. putextra (intent. extra_subject, "The Email Subject text ");
8. It. settype ("message/rfc822 ″);
9. startactivity (intent. createchooser (it, "choose email client "));

Add attachment

1. Intent it = new intent (intent. action_send );
2. it. putextra (intent. extra_subject, "The Email Subject text ");
3. It. putextra (intent. extra_stream, "file: // sdcard/mysong.mp3 ″);
4. sendintent. settype ("audio/MP3 ″);
5. startactivity (intent. createchooser (it, "choose email client "));

Play multimedia

1. Intent it = new intent (intent. action_view );
2. Uri uri = URI. parse ("file: // sdcard/song.mp3 ″);
3. It. setdataandtype (Uri, "audio/MP3 ″);
4. startactivity (it );

1. Uri uri = URI. withappendedpath (mediastore. Audio. Media. internal_content_uri, "1 ″);
2. Intent it = new intent (intent. action_view, Uri );
3. startactivity (it );

Uninstall program

1. Uri uri = URI. fromparts ("package", strpackagename, null );
2. Intent it = new intent (intent. action_delete, Uri );
3. startactivity (it );

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.