Android Reprint Six: intent.action

Source: Internet
Author: User

This article describes the various common functions of intent in Android.

1 Intent.action_main

String:android.intent.action.MAIN

Identifies the activity as the start of a program. More commonly used.

Input:nothing

Output:nothing

<ActivityAndroid:name=". Main "Android:label= "@string/app_name"><intent-filter >          <action android:name= " Android.intent.action.MAIN " />           < Category android:name= " Android.intent.category.LAUNCHER " />       </intent-filter> </Activity>

2 Intent.action_call

Stirng:android.intent.action.CALL

Call the specified phone number.

Input: Phone number. The data format is: Tel:+phone number

Output:nothing

Intent intent=new Intent ();

Intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("tel:1320010001"); StartActivity (intent);

3 Intent.Action.DIAL

String:action.intent.action.DIAL

Call Dial Panel

Intent intent=new Intent ();Intent.setaction (intent.action_dial);//Android.intent.action.DIAL intent.setdata (Uri.parse ("tel:1320010001"); startactivity (intent);

Input: Phone number. The data format is: Tel:+phone number

Output:nothing

Description: Opens the dial-up UI for Android. If no data is set, open an empty UI if you set the data, action. Dial gets the phone number by calling GetData ().

However, the data format for setting the phone number is tel:+phone.

4 Intent.Action.ALL_APPS

String:andriod.intent.action.ALL_APPS

List all the apps.

Input:nothing.

Output:nothing.

5 Intent.action_answer

Stirng:android.intent.action.ANSWER

Process incoming calls.

Input:nothing.

Output:nothing.

6 Intent.action_attach_data

String:android.action.ATTCH_DATA

Do not specify that some data should be attached to some other place, for example, the picture data should be attached to the contact

Input:data

Output:nothing

7 Intent.action_bug_report

String:android.intent.action.BUG_REPORT

Displays the dug report.

Input:nothing

Output:nothing

8 Intent.action_call_button

String:android.action.intent.CALL_BUTTON.

Equivalent to the user pressing the "Dial" key. The test shows "call history."

Input:nothing

Output:nothing

Intent Intent =new Intent (Intent.action_call_button);StartActivity (Intent);

9 Intent.action_chooser

String:android.intent.action.CHOOSER

Displays an activity selector that allows the user to select what they want before the process, corresponding to the intent.action_get_content.

Ten. Intent.action_get_content

String:android.intent.action.GET_CONTENT

Allows the user to select a particular kind of data and return (special kind of data: take a photo or record a piece of music)

Input:type

Output:uri

int requestcode = 1001;Intent Intent =new Intent (intent.action_get_content); // "Android.intent.action.GET_CONTENT" intent.settype ("image/*"); // view type, if other type, such as video is replaced with video/*, or */* Intent wrapperintent = Intent.createchooser (Intent, null);

Startactivityforresult (Wrapperintent, Requestcode);

Intent.action_view

String Android.intent.action.VIEW

Used to display the user's data.

More general, the corresponding activity is opened based on the user's data type.

For example, tel:13400010001 open the dialer, http://www.g.cn will open the browser and so on.

Uri uri = uri.parse ("http://www.google.com");// browser URI Uri =uri.parse ("tel:1232333");// dialer Uri uri=uri.parse ("geo:39.899533,116.036476"); // Open map location Intent it = new Intent (Intent.action_view,uri); startactivity (it);

// play video Intent Intent = new Intent (Intent.action_view);  Uri uri = uri.parse ("File:///sdcard/media.mp4");  Intent.setdataandtype (URI, "video/*"); StartActivity (intent); // Call the program that sends the SMS Intent it = new Intent (Intent.action_view); It.putextra ("Sms_body", "Information content ...");  It.settype ("vnd.android-dir/mms-sms"); StartActivity (it);

Intent.action_sendto

String:android.intent.action.SENDTO Description: Send SMS

// send SMS Uri uri = uri.parse ("smsto:13200100001"); Intent it =New Intent (Intent.action_sendto, URI);  It.putextra ("Sms_body", "Information content ..."); StartActivity (IT);

// send MMS, the device will prompt to select the appropriate program to send Uri uri = uri.parse ("Content://media/external/images/media/23");// resources in the device (images or other resources) Intent Intent = new Intent (intent.action_send);  Intent.putextra ("Sms_body", "content");  Intent.putextra (Intent.extra_stream, URI);  Intent.settype ("Image/png"); StartActivity (it);

//Email Intent intent=new Intent (intent.action_send);  String[] tos={"[Email protected]"};  String[] ccs={"[Email protected]"};  Intent.putextra (Intent.extra_email, TOS);  Intent.putextra (INTENT.EXTRA_CC, CCS);  Intent.putextra (Intent.extra_text, "The email body TEXT");  Intent.putextra (Intent.extra_subject, "The email SUBJECT text");  Intent.settype ("message/rfc822"); StartActivity (Intent.createchooser (Intent, "Choose Email Client"));

Intent.action_get_content

// Select picture requestcode return identification Intent Intent = new Intent (intent.action_get_content); //"Android.intent.action.GET_CONTENT" Intent.settype (ContentType); // view type String image_unspecified = "image/*"; Intent wrapperintent = Intent.createchooser (Intent, null);  ( Activity) context). Startactivityforresult (Wrapperintent, Requestcode);

// Add audio Intent Intent = new Intent (intent.action_get_content); Intent.settype (ContentType); //String video_unspecified = "video/*"; Intent wrapperintent = Intent.createchooser (Intent, null);  ( Activity) context). Startactivityforresult (Wrapperintent, Requestcode);

 // shooting video   int durationlimit = getvideocapturedurationlimit ();  < Span style= "color: #008000;" >//systemproperties.getint ("Ro.media.enc.lprof.duration",  60); Intent intent = new intent (Mediastore.action_video_capture) ; Intent.putextra (mediastore.extra_video_quality, 0); Intent.putextra (Mediastore.extra_size_limit, sizelimit); Intent.putextra (Mediastore.extra_duration_limit, durationlimit); Startactivityforresult (Intent, request_code_take_video);

// video Intent Intent = new Intent (intent.action_get_content); Intent.settype (ContentType); //String video_unspecified = "video/*"; Intent wrapperintent = Intent.createchooser (Intent, null);  ( Activity) context). Startactivityforresult (Wrapperintent, Requestcode);

// recording Intent Intent = new Intent (intent.action_get_content); Intent.settype (CONTENTTYPE.AUDIO_AMR); //String audio_amr = "Audio/amr"; intent.setclassname ("Com.android.soundrecorder", " Com.android.soundrecorder.SoundRecorder ");  ( Activity) context). Startactivityforresult (Intent, Requestcode);

// photo  REQUEST_CODE_TAKE_PICTURE  for the returned identity Span style= "color: #008000;" > Intent intent = new intent (Mediastore.action_image_capture) ;  // Intent.putextra (Mediastore.extra_output, mms.scrapspace.content_uri);  // output,uri.parse ("Content://mms/scrapspace "); startactivityforresult ( intent, request_code_take_picture);   

Complete. ^_^

Android Reprint Six: intent.action

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.