Android Intent and intent action Daquan

Source: Internet
Author: User

usage of 1.Intent:(1) Jump with action1, use the action jump, if there is a program in the androidmanifest.xml of an activityThe intentfilter section defines the same action that is included in theThen this intent is matched to this target action. If type,category is not defined in this intentfilter segment, then the activity is matched.But if you have more than two programs in your phone, a dialog box will pop up to show you the message. The value of Action has a lot of pre-defined in Android,If you want to go directly to your own defined intent receiver, you can add a custom action value to the recipient's Intentfilter(also set the category value to "Android.intent.category.DEFAULT"), in your intent set the value as intent Action, you can jump directly to your own intent receiver. Because this action is unique in the system. 2,data/type, you can use URIs as data, such as URI uri = Uri.parse (http://www.google.com);
Intent i = new Intent (Intent.action_view,uri); During the Intent distribution of the cell phone, the type of data is judged according to the http://www.google.com scheme. The brower of the phone can match it, in the Brower manifest.xml intenfilter First has Action_view Action, also can handle http: type, 3, as for the classification category, Generally do not go to set it in intent, if you write intent receiver, in manifest.xml activity Intentfilter contains Android.category.DEFAULT, so that all do not set The Intent of category (Intent.addcategory (String c);) will match this category. 4,extras (additional information), is a collection of all other additional information. You can use extras to provide extended information for your component, such as, if you want to perform the "Send e-mail" action, you can save the e-mail message's title, body, and so on in extras, to the e-mail sending component.(2) Jump with class nameIntent is responsible for the action of an operation in the application, the action involves data, the additional data is described, Android according to this intent description, is responsible to find the corresponding component, the intent passed to the calling component, and complete the call of the component. Intent is where the decoupling between the caller and the callee is implemented. In the intent delivery process, the target consumer (another activity,intentreceiver or service) is found, that is, the responder of intent. Intent Intent = new Intent ();
Intent.setclass (context, targetactivy.class);
or directly with Intent Intent = new Intent (context, targetactivity.class); StartActivity (Intent);but note that using the class name to jump, you need to declare activity in Androidmanifest.xml<activity android:name= "Targetactivity" ></activity>2. Usage of several intentIntent is often used in Android. Whether it is the page pull, or pass data, or call external programs, the system functions are used to intent. After doing some examples of intent, finishing a bit of intent, hope to be useful to everyone. Because intent content too much, can not really write full, inevitably will have left behind, I will be updated at any time. If you have questions or new intent content, want to communicate.
★intent Daquan:
1. Search content from Google
Intent Intent = new Intent ();
Intent.setaction (Intent.action_web_search);
Intent.putextra (Searchmanager.query, "searchstring")
StartActivity (Intent);

2. Browse the Web
Uri uri = uri.parse ("http://www.google.com");
Intent it = new Intent (Intent.action_view,uri);
StartActivity (IT);

3. Show Map
Uri uri = uri.parse ("geo:38.899533,-77.036476");
Intent it = new Intent (Intent.action_view,uri);
StartActivity (IT);

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

5. Make a phone call
Uri uri = uri.parse ("tel:xxxxxx");
Intent it = new Intent (intent.action_dial, URI);
StartActivity (IT);

6. Call the program to send SMS
Intent it = new Intent (Intent.action_view);
It.putextra ("Sms_body", "The SMS Text");
It.settype ("vnd.android-dir/mms-sms");
StartActivity (IT);

7. 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);
String body= "This is SMS Demo";
Intent mmsintent = new Intent (intent.action_sendto, Uri.fromparts ("Smsto", number, null));
Mmsintent.putextra (Messaging.key_action_sendto_message_body, BODY);
Mmsintent.putextra (Messaging.key_action_sendto_compose_mode, true);
Mmsintent.putextra (Messaging.key_action_sendto_exit_on_sent, true);
StartActivity (mmsintent);

8. 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);
StringBuilder sb = new StringBuilder ();
Sb.append ("file://");
Sb.append (Fd.getabsolutefile ());
Intent Intent = new Intent (intent.action_sendto, Uri.fromparts ("Mmsto", number, null));
Below Extra datas is all optional.
Intent.putextra (Messaging.key_action_sendto_message_subject, SUBJECT);
Intent.putextra (Messaging.key_action_sendto_message_body, BODY);
Intent.putextra (Messaging.key_action_sendto_content_uri, sb.tostring ());
Intent.putextra (Messaging.key_action_sendto_compose_mode, Composemode);
Intent.putextra (Messaging.key_action_sendto_exit_on_sent, exitonsent);
StartActivity (Intent);

9. 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"));

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

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

11.uninstall apk
Uri uri = uri.fromparts ("package", strpackagename, NULL);
Intent it = new Intent (Intent.action_delete, URI);
StartActivity (IT);

12.install apk
Uri Installuri = uri.fromparts ("package", "XXX", null);
Returnit = new Intent (intent.action_package_added, Installuri);

13. Turn on the camera
<1>intent i = new Intent (Intent.action_camera_button, NULL);
This.sendbroadcast (i);
<2>long Datetaken = System.currenttimemillis ();
String name = Createname (Datetaken) + ". jpg";
FileName = folder + name;
Contentvalues values = new Contentvalues ();
Values.put (Images.Media.TITLE, fileName);
Values.put ("_data", fileName);
Values.put (Images.Media.PICASA_ID, fileName);
Values.put (Images.Media.DISPLAY_NAME, fileName);
Values.put (Images.Media.DESCRIPTION, fileName);
Values.put (Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName);
Uri Photouri = Getcontentresolver (). Insert (
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

Intent Inttphoto = new Intent (mediastore.action_image_capture);
Inttphoto.putextra (Mediastore.extra_output, Photouri);
Startactivityforresult (Inttphoto, 10);

14. Select a picture from gallery
Intent i = new Intent ();
I.settype ("image/*");
I.setaction (intent.action_get_content);
Startactivityforresult (i, 11);

15. Turn on the recorder
Intent mi = new Intent (media.record_sound_action);
StartActivity (MI);

16. Show App Detail List
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

Just looking for the app ID has not been found, the result finds the package name can also
Uri uri = uri.parse ("market://details?id=<packagename>");
That's a lot easier.

17 Finding applications
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 for an application

18 Open a contact list
<1>
Intent i = new Intent ();
I.setaction (intent.action_get_content);
I.settype ("Vnd.android.cursor.item/phone");
Startactivityforresult (i, request_text);

<2>
Uri uri = uri.parse ("Content://contacts/people");
Intent it = new Intent (Intent.action_pick, URI);
Startactivityforresult (it, request_text);

19 Open Another program
Intent i = new Intent ();
ComponentName cn = New ComponentName ("Com.yellowbook.android2",
"Com.yellowbook.android2.AndroidSearch");
I.setcomponent (CN);
I.setaction ("Android.intent.action.MAIN");
Startactivityforresult (i, RESULT_OK); 20. Call System Editor to add a contact (the High version SDK is valid):
Intent it = newintent (Intent.action_insert_or_edit);
It.settype ("Vnd.android.cursor.item/contact");
It.settype (Contacts.content_item_type);
It.putextra ("name", "MyName");
It.putextra (Android.provider.Contacts.Intents.Insert.COMPANY, "organization");
It.putextra (Android.provider.Contacts.Intents.Insert.EMAIL, "EMAIL");
It.putextra (Android.provider.Contacts.Intents.Insert.PHONE, "HomePhone");
It.putextra (Android.provider.Contacts.Intents.Insert.SECONDARY_PHONE,
"Mobilephone");
It.putextra (Android.provider.Contacts.Intents.Insert.TERTIARY_PHONE,
"Workphone");
It.putextra (Android.provider.Contacts.Intents.Insert.JOB_TITLE, "TITLE");
StartActivity (IT);

21. Call system Edit Add contact (all valid):
Intent Intent = newintent (Intent.action_insert_or_edit);
Intent.settype (People.content_item_type);
Intent.putextra (Contacts.Intents.Insert.NAME, "My NAME");
Intent.putextra (Contacts.Intents.Insert.PHONE, "+1234567890");
Intent.putextra (Contacts.intents.insert.phone_type,contacts.phonescolumns.type_mobile);
Intent.putextra (Contacts.Intents.Insert.EMAIL, "[EMAIL protected]");
Intent.putextra (Contacts.Intents.Insert.EMAIL_TYPE, Contacts.ContactMethodsColumns.TYPE_WORK);
StartActivity (Intent);

★intent Action Daquan:
  • Android.intent.action.ALL_APPS
  • Android.intent.action.ANSWER
  • Android.intent.action.ATTACH_DATA
  • Android.intent.action.BUG_REPORT
  • Android.intent.action.CALL
  • Android.intent.action.CALL_BUTTON
  • Android.intent.action.CHOOSER
  • Android.intent.action.CREATE_LIVE_FOLDER
  • Android.intent.action.CREATE_SHORTCUT
  • Android.intent.action.DELETE
  • Android.intent.action.DIAL
  • Android.intent.action.EDIT
  • Android.intent.action.GET_CONTENT
  • Android.intent.action.INSERT
  • Android.intent.action.INSERT_OR_EDIT
  • Android.intent.action.MAIN
  • Android.intent.action.MEDIA_SEARCH
  • Android.intent.action.PICK
  • Android.intent.action.PICK_ACTIVITY
  • Android.intent.action.RINGTONE_PICKER
  • Android.intent.action.RUN
  • Android.intent.action.SEARCH
  • Android.intent.action.SEARCH_LONG_PRESS
  • Android.intent.action.SEND
  • Android.intent.action.SENDTO
  • Android.intent.action.SET_WALLPAPER
  • Android.intent.action.SYNC
  • Android.intent.action.SYSTEM_TUTORIAL
  • Android.intent.action.VIEW
  • Android.intent.action.VOICE_COMMAND
  • Android.intent.action.WEB_SEARCH
  • Android.net.wifi.PICK_WIFI_NETWORK
  • Android.settings.AIRPLANE_MODE_SETTINGS
  • Android.settings.APN_SETTINGS
  • Android.settings.APPLICATION_DEVELOPMENT_SETTINGS
  • Android.settings.APPLICATION_SETTINGS
  • Android.settings.BLUETOOTH_SETTINGS
  • Android.settings.DATA_ROAMING_SETTINGS
  • Android.settings.DATE_SETTINGS
  • Android.settings.DISPLAY_SETTINGS
  • Android.settings.INPUT_METHOD_SETTINGS
  • Android.settings.INTERNAL_STORAGE_SETTINGS
  • Android.settings.LOCALE_SETTINGS
  • Android.settings.LOCATION_SOURCE_SETTINGS
  • Android.settings.MANAGE_APPLICATIONS_SETTINGS
  • Android.settings.MEMORY_CARD_SETTINGS
  • Android.settings.NETWORK_OPERATOR_SETTINGS
  • Android.settings.QUICK_LAUNCH_SETTINGS
  • Android.settings.SECURITY_SETTINGS
  • Android.settings.SETTINGS
  • Android.settings.SOUND_SETTINGS
  • Android.settings.SYNC_SETTINGS
  • Android.settings.USER_DICTIONARY_SETTINGS
  • Android.settings.WIFI_IP_SETTINGS
  • Android.settings.WIFI_SETTINGS
  • Android.settings.WIRELESS_SETTINGS
Reprinted from: http://www.ophonesdn.com/forum/thread-2609-1-1.html

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.