Intent should be something peculiar to Android. You can specify the actions to be performed by the program (for example: view,edit,dial) in intent, and the data that the program needs to perform the action. Once specified, the Android system automatically finds the application that best meets your requirements and executes the program whenever StartActivity () is called.
Here are a list of the usage of several intent
Show Web page:
Uri uri = uri.parse ("http://www.google.com");
Intent it = new Intent (Intent.action_view,uri);
StartActivity (IT);
Show 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=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en ");
Intent it = new Intent (Intent.action_view,uri);
StartActivity (IT);
Dial number:
Calling a dial-up 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 you must add <uses-permission id= "Android. Permission in the configuration file. Call_phone "/>
Send Sms/mms:
Call the program that sent the SMS
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:[email protected]");
Intent it = new Intent (intent.action_sendto, URI);
StartActivity (IT);
Intent it = new Intent (intent.action_send);
It.putextra (Intent.extra_email, "[email protected]");
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={"[email protected]"};
String[] ccs={"[email protected]"};
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"));
To add an 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"),
Play Multimedia:
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);
Uninstall APK
Uri Uninstalluri = uri.fromparts ("package", "XXX", null);
Returnit = new Intent (Intent.action_delete, Uninstalluri);
Install APK
Uri Installuri = uri.fromparts ("package", "XXX", null);
Returnit = new Intent (intent.action_package_added, Installuri);
Play Audio
Uri Playuri = Uri.parse ("File:///sdcard/download/everything.mp3");
Returnit = new Intent (Intent.action_view, Playuri);
//Send attachment:
Intent it = new Intent (intent.action_send);
It.putextra (Intent.extra_subject, "The email SUBJECT text");
It.putextra (Intent.extra_stream, "File:///sdcard/eoe.mp3");
Sendintent.settype ("Audio/mp3") );
StartActivity (Intent.createchooser (it, "Choose Email Client");
//Search app:
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 application
Displays the detailed page for the specified app (this does not seem to support the app_id):
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 in market home
page, and notice the ID from the address bar
Several usages of intent