Summary of various common functions of Intent. Action in Android development
- 2021-10-25 07:59:38
- OfStack
This paper introduces various common functions of Intent in Android.
1 Intent.ACTION_MAIN
String: android.intent.action.MAIN
Identifies Activity as the start of 1 program. More commonly used.
Input:nothing
Output:nothing
<activity android: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 telephone number.
Input: Telephone 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);
When using Intent. ACTION_CALL, you must add in AndroidManifest. xml < uses-permission android:name="android.permission.CALL_PHONE" / > You have gained permission to make a call. Intent.ACTION_CALL is different from Intent.ACTION_DIALOG in that Intent.ACTION_DIALOG simply calls the dialing keypad to copy the phone number, while Intent.ACTION_CALL makes a direct call
3 Intent.Action.DIAL
String: action.intent.action.DIAL
Call the dialing panel
Intent intent=new Intent();
intent.setAction(Intent.ACTION_DIAL); //android.intent.action.DIAL
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
Input: Telephone number. The data format is: tel: + phone number
Output:Nothing
Description: Dial UI to open Android. If no data is set, an empty UI is opened, and if data is set, action. DIAL gets the phone number by calling getData ().
But set the data format for the phone number to tel: + phone number.
4 Intent.Action.ALL_APPS
String: andriod.intent.action.ALL_APPS
List all applications.
Input: Nothing.
Output:Nothing.
5 Intent.ACTION_ANSWER
Stirng:android.intent.action.ANSWER
Handle incoming calls.
Input:Nothing.
Output:Nothing.
6 Intent.ACTION_ATTACH_DATA
String: android.action.ATTCH_DATA
Don't use it to specify that 1 data should be attached to 1 other place, for example, picture data should be attached to contacts
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 record"
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 users to select what they want before the process, corresponding to Intent. ACTION_GET_CONTENT.
10. Intent.ACTION_GET_CONTENT
String: android.intent.action.GET_CONTENT
Allows the user to select a special kind of data and return (special kind of data: take a photo or record a sound)
Input: Type
Output:URI
int requestCode = 1001;
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
intent.setType("image/*"); // View the type, and if it is another type, such as video, replace it with video/* , or */*
Intent wrapperIntent = Intent.createChooser(intent, null);
startActivityForResult(wrapperIntent, requestCode);
11 Intent.ACTION_VIEW
Stirng: android.intent.action.CALL
0
Used to display user data.
It is more general, and the corresponding Activity will be opened according to the user's data type.
For example, tel: 13400010001 opens the dialing program, and http://www.g.cn opens the browser.
Uri uri = Uri.parse("http://www.google.com"); // Browser
Uri uri =Uri.parse("tel:1232333"); // Dialing program
Uri uri=Uri.parse("geo:39.899533,116.036476"); // Open map positioning
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 short messages
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", " Information content ...");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
12 Intent.ACTION_SENDTO
String: android.intent.action.SENDTO
Description: Send SMS
// Send a short message
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 be prompted to select the appropriate program to send
Uri uri = Uri.parse("content://media/external/images/media/23");
// Resources (images or other resources) in the device
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", " Content ");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
startActivity(it);
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
0
13 Intent.ACTION_GET_CONTENT
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
1
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
2
// Shoot a video
int durationLimit = getVideoCaptureDurationLimit(); //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);
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
4
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
5
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);
6
Over. ^ _ ^
Summarize