Turn from: here
An Android system for activity standard Intent 1 display contact information based on contact ID
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view); //Show contact information
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
2 Display dial-up panel based on contact ID
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_dial); //Display dial-up panel
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
3 Display the dialer panel and display the number on the Dial panel
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view);
- Intent.setdata (Uri.parse ("tel://15216448315"));
- StartActivity (Intent);
4 Display the dialer panel and display the number on the Dial panel
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_dial); //Display the dialer panel and display the number on the Dial panel
- Intent.setdata (Uri.parse ("tel://15216448315"));
- StartActivity (Intent);
5 Edit contacts based on the ID of the contact person
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_edit); //Edit Contacts
- Intent.setdata (Uri.parse ("content://contacts/people/492"));
- StartActivity (Intent);
6 displays a list of contacts and other account contacts for the contact person
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_view);
- Intent.setdata (Uri.parse ("content://contacts/people/"));
- StartActivity (Intent);
7 Start homescreen
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_main); //Start homescreen
- Intent.addcategory (Intent.category_home);
- StartActivity (Intent);
8 Select a contact's number and return a URI that represents this number, such as: content://contacts/phones/982
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_get_content);
- Intent.settype ("Vnd.android.cursor.item/phone");
- Startactivityforresult (Intent, 1);
9 Open multiple Apps Select various types of data to return as URIs. The returned URI can be opened using Contentresolver.openinputstream (URI)
This feature can be used to select attachments in a message
Examples are as follows:
Select a picture and return the URI as CONTENT://MEDIA/EXTERNAL/IMAGES/MEDIA/47
Choose a song that returns a URI of CONTENT://MEDIA/EXTERNAL/AUDIO/MEDIA/51
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_get_content);
- Intent.settype ("*/*");
- Intent.addcategory (intent.category_openable);
- Startactivityforresult (Intent, 2);
10 Customizing a Chooser, not using the system's Chooser
The chooser can have its own caption (title)
And you don't have to specify preferences
[Java]View Plaincopy
- intent intent = new Intent ();
- intent.setaction (intent.action_chooser);
- intent.putextra (Intent.extra_title, "My chooser");
- Intent.putextra (intent.extra_intent,
- new intent (intent.action_get_content)
- .settype ( "*/*")
- .addcategory (Intent.CATEGORY _openable)
- );
-   
- Startactivityforresult (Intent, 2);
11 Select activity, the returned activity can be obtained in the Returned Intent.getcomponent ()
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (intent.action_pick_activity);
- Intent.putextra (Intent.extra_intent,
- new Intent (intent.action_get_content)
- . SetType ("*/*")
- . Addcategory (Intent.category_openable)
- );
- Startactivityforresult (Intent, 3);
12 Start the search, in the following sample code, "ANDROID" is the string to search for
When this code is executed, a list of programs that can be used for searching is displayed in the system's Chooser
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_search); //Start Search
- Intent.putextra (Searchmanager.query, "ANDROID");
- StartActivity (Intent);
13 Start web Search, in the following sample code, "ANDROID" is the string to search for
When this code is executed, a list of programs that can be used for searching is displayed in the system's chooser, and in general the browsers installed in the system will be displayed
[Java]View Plaincopy
- Intent Intent = new Intent ();
- Intent.setaction (Intent.action_web_search); //Start Search
- Intent.putextra (Searchmanager.query, "ANDROID");
- StartActivity (Intent);
Two Android system for Broadcastreceiver standard Intent 1 Action_time_tick, System clock broadcast, the system sends one such broadcast every minute, if in the application development, some logic relies on the system clock, Can register a broadcast receiver this is a protected action and only the system can send this broadcast and the broadcast recipient registered in the manifest file cannot receive the broadcast, and the broadcast recipient must be registered in the code to receive the broadcast
[Java]View Plaincopy
- Registerreceiver (new Broadcastreceiver () {
- @Override
- public void OnReceive (context context, Intent Intent) {
- LOG.I ("xxxx", "Time_tick");
- }
- },
- New Intentfilter (Intent.action_time_tick));
2 in the official documentation, the following standard broadcast action is listed
ACTION_TIME_TICK 系统时钟广播
ACTION_TIME_CHANGED 时间被重新设置
ACTION_TIMEZONE_CHANGED 时区改变
ACTION_BOOT_COMPLETED 系统启动完成
ACTION_PACKAGE_ADDED 系统中安装了新的应用
ACTION_PACKAGE_CHANGED 系统中已存在的app包被更改
ACTION_PACKAGE_REMOVED 系统中已存在的app被移除
ACTION_PACKAGE_RESTARTED 用户重启了一个app,这个app的所有进程被杀死
ACTION_PACKAGE_DATA_CLEARED 用户清除了一个app的数据
ACTION_UID_REMOVED 系统中的一个user ID被移除
ACTION_BATTERY_CHANGED 电池状态改变,这是一个sticky广播
ACTION_POWER_CONNECTED 设备连接了外部电源
ACTION_POWER_DISCONNECTED 外部电源被移除
ACTION_SHUTDOWN 设备正在关机
The three standard category categories (category) in Android generally work with action, and the following are the standard categories in the system, which can only be studied in detail when used, due to excessive quantities
CATEGORY_DEFAULT
CATEGORY_BROWSABLE
CATEGORY_TAB
CATEGORY_ALTERNATIVE
CATEGORY_SELECTED_ALTERNATIVE
CATEGORY_LAUNCHER
CATEGORY_INFO
CATEGORY_HOME
CATEGORY_PREFERENCE
CATEGORY_TEST
CATEGORY_CAR_DOCK
CATEGORY_DESK_DOCK
CATEGORY_LE_DESK_DOCK
CATEGORY_HE_DESK_DOCK
CATEGORY_CAR_MODE
CATEGORY_APP_MARKET
Standard extra key values in quad Android These constants are used to pass data as key values when calling Intent.putextra (String, Bundle), and also because of the large number of indexes listed here
EXTRA_ALARM_COUNT
EXTRA_BCC
EXTRA_CC
EXTRA_CHANGED_COMPONENT_NAME
EXTRA_DATA_REMOVED
EXTRA_DOCK_STATE
EXTRA_DOCK_STATE_HE_DESK
EXTRA_DOCK_STATE_LE_DESK
EXTRA_DOCK_STATE_CAR
EXTRA_DOCK_STATE_DESK
EXTRA_DOCK_STATE_UNDOCKED
EXTRA_DONT_KILL_APP
EXTRA_EMAIL
EXTRA_INITIAL_INTENTS
EXTRA_INTENT
EXTRA_KEY_EVENT
EXTRA_ORIGINATING_URI
EXTRA_PHONE_NUMBER
EXTRA_REFERRER
EXTRA_REMOTE_INTENT_TOKEN
EXTRA_REPLACING
EXTRA_SHORTCUT_ICON
EXTRA_SHORTCUT_ICON_RESOURCE
EXTRA_SHORTCUT_INTENT
EXTRA_STREAM
EXTRA_SHORTCUT_NAME
EXTRA_SUBJECT
EXTRA_TEMPLATE
EXTRA_TEXT
EXTRA_TITLE
EXTRA_UID
The flag in the intent (flag) Intent class defines some of the flags that begin with flag_, some of which are important and affect the behavior of activity and Broadcastreceiver in the app. The following is an index of these flags, from the official documentation. This will be followed by a detailed analysis of the important signs.
Go: Intent Introduction