SoFunction
Updated on 2025-03-11

A summary of various common roles in Android development

This article introduces various common functions of Intent in Android.

1 Intent.ACTION_MAIN

String:

Identifies the Activity as the beginning of a program. More commonly used.

Input:nothing

Output:nothing

<activity android:name=".Main" android:label="@string/app_name">  
<intent-filter>
     <action android:name="" />
     <category android:name="" />
   </intent-filter>
</activity> 

2 Intent.Action_CALL

Stirng:

Call the specified phone number.

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

Output:Nothing 

Intent intent=new Intent(); 
(Intent.ACTION_CALL);  
(("tel:1320010001");
startActivity(intent);

When using Intent.ACTION_CALL, you must add <uses-permission android:name=".CALL_PHONE" /> to the call. Intent.ACTION_CALL is different from Intent.ACTION_DIALOG. Intent.ACTION_DIALOG just calls the dialing keyboard and copy the phone number, while Intent.ACTION_CALL makes a call directly.

3

String:

Calling the dial panel

Intent intent=new Intent();
(Intent.ACTION_DIAL);  //
(("tel:1320010001");
startActivity(intent); 

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

Output:Nothing

Description: Open the dialing UI for Android. If data is not set, an empty UI is opened, and if data is set, the phone number is obtained by calling getData().

But set the data format of the phone number to tel:+phone number.

4 .ALL_APPS

String: .ALL_APPS

List all applications.

Input:Nothing.

Output:Nothing.

5 Intent.ACTION_ANSWER

Stirng:

Process incoming calls.

Input:Nothing.

Output:Nothing.

6 Intent.ACTION_ATTACH_DATA

String: .ATTCH_DATA

Don't use it to specify that some data should be attached to some other place, for example, image data should be attached to the contact person

Input: Data

Output:nothing

7 Intent.ACTION_BUG_REPORT

String: .BUG_REPORT

Show Dug report.

Input:nothing

output:nothing

8 Intent.Action_CALL_BUTTON

String: .CALL_BUTTON.

It is 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:

Displays an activity selector that allows users to select what they want before the process, corresponding to Intent.ACTION_GET_CONTENT.

10. Intent.ACTION_GET_CONTENT

String: .GET_CONTENT

Allow users to select special types of data and return (special types of data: take a photo or record a sound)

Input: Type

Output:URI

int requestCode = 1001;
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // ".GET_CONTENT"
("image/*"); // View the type, if it is another type, such as video, replace it with video/*, or */*
Intent wrapperIntent = (intent, null);
startActivityForResult(wrapperIntent, requestCode); 

11 Intent.ACTION_VIEW

String

Used to display user data.

It is more common, and the corresponding activity will be opened according to the user's data type.

For example, tel:13400010001 opens the dialing program,The browser will be opened, etc.

Uri uri = (""); //BrowserUri uri =("tel:1232333"); //Dialling programUri uri=("geo:39.899533,116.036476"); //Open the map to locateIntent it = new Intent(Intent.ACTION_VIEW,uri); 
startActivity(it); 
//Play videoIntent intent = new Intent(Intent.ACTION_VIEW); 
Uri uri = ("file:///sdcard/media.mp4"); 
(uri, "video/*"); 
startActivity(intent);
//Calling the program that sends text messagesIntent it = new Intent(Intent.ACTION_VIEW);
("sms_body", "Information content..."); 
("-dir/mms-sms"); 
startActivity(it);

12 Intent.ACTION_SENDTO 

String:  

Description: Send a short message

//Send a short messageUri uri = ("smsto:13200100001"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
("sms_body", "Information content..."); 
startActivity(it); 
//Send MMS, the device will prompt you to select the appropriate program to sendUri uri = ("content://media/external/images/media/23"); 
//Resources in the device (image or other resources)Intent intent = new Intent(Intent.ACTION_SEND); 
("sms_body", "content"); 
(Intent.EXTRA_STREAM, uri); 
("image/png"); 
startActivity(it);
//Email 
Intent intent=new Intent(Intent.ACTION_SEND); 
String[] tos={"android1@"}; 
String[] ccs={"you@"}; 
(Intent.EXTRA_EMAIL, tos); 
(Intent.EXTRA_CC, ccs);
 (Intent.EXTRA_TEXT, "The email body text"); 
(Intent.EXTRA_SUBJECT, "The email subject text"); 
("message/rfc822"); 
startActivity((intent, "Choose Email Client"));

13 Intent.ACTION_GET_CONTENT

//Select the image requestCode return logoIntent intent = new Intent(Intent.ACTION_GET_CONTENT); //".GET_CONTENT"
(contentType); //View type String IMAGE_UNSPECIFIED = "image/*";Intent wrapperIntent = (intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//Add audioIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = (intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//Shoot the videoint durationLimit = getVideoCaptureDurationLimit(); //("", 60);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
(MediaStore.EXTRA_VIDEO_QUALITY, 0);
(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
//videoIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = (intent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//recordingIntent intent = new Intent(Intent.ACTION_GET_CONTENT);
(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";
("",
"");
((Activity) context).startActivityForResult(intent, requestCode); 
//Take a photo REQUEST_CODE_TAKE_PICTURE is the returned identifierIntent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //".IMAGE_CAPTURE";
(MediaStore.EXTRA_OUTPUT, .CONTENT_URI); // output,("content://mms/scrapSpace");
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); 

complete. ^_^

Summarize

The above is the entire content of this article. I hope that the content of this article has certain reference value for your study or work. Thank you for your support. If you want to know more about it, please see the relevant links below