Intent It should be something special in Android. You can specify Program The action to be executed (such as view, edit, dial), and Materials . After all settings are specified, you only need to call startactivity (), Android System Will automatically find the most suitable for your specified requirements Application Program, and execute the program.
The usage of several intent types is listed below
Display webpage:
- Uri uri = URI. parse ("http://www.google.com ");
- Intent it = new intent (intent. action_view, Uri );
- Startactivity (it );
Display map:
- Uri uri = URI. parse ("Geo: 38.899533,-77.036476 ");
- Intent it = new intent (intent. action_view, Uri );
- Startactivity (it );
Path 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 );
Call number:
Call the dialup Program
- Uri uri = URI. parse ("Tel: xxxxxx ");
- Intent it = new intent (intent. action_dial, Uri );
- Startactivity (it );
- Uri uri = URI. parse ("Tel. xxxxxx ");
- Intent it = new intent (intent. action_call, Uri );
- To use this function, you must configureFile<Uses-Permission id ="Android. Permission. call_phone "/>
Send SMS/MMS
Send callSMSProgram
- Intent it = new intent (intent. action_view );
- It. putextra ("sms_body", "the SMS text ");
- It. settype ("Vnd. Android-DIR/MMS-SMS ");
- Startactivity (it );
Send SMS
- Uri uri = URI. parse ("smsto: 0800000123 ");
- Intent it = new intent (intent. action_sendto, Uri );
- It. putextra ("sms_body", "the SMS text ");
- Startactivity (it );
Send MMS
- Uri uri = URI. parse ("content: // media/external/images/Media/23 ");
- Intent it = new intent (intent. action_send );
- It. putextra ("sms_body", "some text ");
- It. putextra (intent. extra_stream, Uri );
- It. settype ("image/PNG ");
- Startactivity (it );
Send email
- Uri uri = URI. parse ("mailto: xxx@abc.com ");
- Intent it = new intent (intent. action_sendto, Uri );
- Startactivity (it );
- intent it = new intent (intent. action_send);
- it. putextra (intent. extra_email, "me@abc.com");
- it. putextra (intent. extra_text, "the email body text");
- it. settype ("text/plain");
- startactivity (intent. createchooser (IT, "Choose email client");
- Intent it = new intent (intent. action_send );
- String [] TOS = {"me@abc.com "};
- String [] CCS = {"you@abc.com "};
- It. putextra (intent. extra_email, TOS );
- It. putextra (intent. extra_cc, CCS );
- It. putextra (intent. extra_text, "the email body text ");
- It. putextra (intent. extra_subject, "the email subject text ");
- It. settype ("message/rfc822 ");
- Startactivity (intent. createchooser (IT, "Choose email client "));
Add attachment
- Intent it = new intent (intent. action_send );
- It. putextra (intent. extra_subject, "the email subject text ");
- It. putextra (intent. extra_stream, "file: // sdcard/mysong.mp3 ");
- Sendintent. settype ("audio/MP3 ");
- Startactivity (intent. createchooser (IT, "Choose email client "));
PlayMultimedia
- Intent it = new intent (intent. action_view );
- Uri uri = URI. parse ("file: // sdcard/song.mp3 ");
- It. setdataandtype (Uri, "audio/MP3 ");
- Startactivity (it );
- Uri uri = URI. withappendedpath (mediastore. Audio. Media. internal_content_uri, "1 ");
- Intent it = new intent (intent. action_view, Uri );
- Startactivity (it );
Uninstall program
- Uri uri = URI. fromparts ("package", strpackagename, null );
- Intent it = new intent (intent. action_delete, Uri );
- Startactivity (it );