Intent中常見的Action

1 Intent.ACTION_MAINandroid

String: android.intent.action.MAIN瀏覽器

標識Activity爲一個程序的開始。比較經常使用。app

Input:nothingide

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>google

2 Intent.Action_CALL視頻

Stirng: android.intent.action.CALL進程

呼叫指定的電話號碼。圖片

Input:電話號碼。數據格式爲: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

調用撥號面板

Intent intent=new Intent();

intent.setAction(Intent.ACTION_DIAL);

//android.intent.action.DIAL
intent.setData(Uri.parse("tel:1320010001");
startActivity(intent);

 

Input:電話號碼。數據格式爲:tel:+phone number

Output:Nothing

說明:打開Android的撥號UI。若是沒有設置數據,則打開一個空的UI,若是設置數據,action.DIAL則經過調用getData()獲取電話號碼。

但設置電話號碼的數據格式爲 tel:+phone number.

4 Intent.Action.ALL_APPS

String: andriod.intent.action.ALL_APPS

列出全部的應用。

Input:Nothing.

Output:Nothing.

5 Intent.ACTION_ANSWER

Stirng:android.intent.action.ANSWER

處理呼入的電話。

Input:Nothing.

Output:Nothing.

6 Intent.ACTION_ATTACH_DATA

String: android.action.ATTCH_DATA

別用於指定一些數據應該附屬於一些其餘的地方,例如,圖片數據應該附屬於聯繫人

Input: Data

Output:nothing

7 Intent.ACTION_BUG_REPORT

String: android.intent.action.BUG_REPORT

顯示Dug報告。

Input:nothing

output:nothing

8 Intent.Action_CALL_BUTTON

String: android.action.intent.CALL_BUTTON.

至關於用戶按下「撥號」鍵。經測試顯示的是「通話記錄」

Input:nothing

Output:nothing

Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);startActivity(intent);

9 Intent.ACTION_CHOOSER

String: android.intent.action.CHOOSER

顯示一個activity選擇器,容許用戶在進程以前選擇他們想要的,與之對應的是Intent.ACTION_GET_CONTENT.

10. Intent.ACTION_GET_CONTENT

String: android.intent.action.GET_CONTENT

容許用戶選擇特殊種類的數據,並返回(特殊種類的數據:照一張相片或錄一段音)

Input: Type

Output:URI

int requestCode = 1001;Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
intent.setType("image/*"); // 查看類型,若是是其餘類型,好比視頻則替換成 video/*,或 */*
Intent wrapperIntent = Intent.createChooser(intent, null);

startActivityForResult(wrapperIntent, requestCode);

 

11 Intent.ACTION_VIEW

String android.intent.action.VIEW

用於顯示用戶的數據。

比較通用,會根據用戶的數據類型打開相應的Activity。

好比 tel:13400010001打開撥號程序,http://www.g.cn則會打開瀏覽器等。

Uri uri = Uri.parse("http://www.google.com"); //瀏覽器 Uri uri =Uri.parse("tel:1232333"); //撥號程序
Uri uri=Uri.parse("geo:39.899533,116.036476"); //打開地圖定位
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);

//播放視頻
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/media.mp4");
intent.setDataAndType(uri, "video/*");
startActivity(intent);
//調用發送短信的程序
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "信息內容...");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);

12 Intent.ACTION_SENDTO

String: android.intent.action.SENDTO 說明:發送短信息

//發送短信息 Uri uri = Uri.parse("smsto:13200100001");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "信息內容...");
startActivity(it);

//發送彩信,設備會提示選擇合適的程序發送 Uri uri = Uri.parse("content://media/external/images/media/23");
//設備中的資源(圖像或其餘資源)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "內容");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
startActivity(it);

 

//Email Intent intent=new Intent(Intent.ACTION_SEND);
String[] tos={"android1@163.com"};
String[] ccs={"you@yahoo.com"};
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"));

 

13 Intent.ACTION_EDIT

爲指定的數據顯示可編輯界面

14 Intent.ACTION_PICK

從數據中選擇一個項目(item),將被選中的項目返回

15 Intent.ACTION_SEND

給別人提供一些數據

16 Intent.ACTION_DELETE

從容器中刪除給定的數據

17 Intent.ACTION_INSERT

在容器中插入一個空項目(item)

18 Intent.ACTION_RUN

運行數據(指定的應用),不管它(應用)是什麼

19 Intent. EXTRA_INTENT

附加數據:和ACTION_PICK_ACTIVITY一塊兒使用時,說明用戶選擇的用來顯示的activity;和ACTION_ADD_SHORTCUT一塊兒使用時,描述要添加的快捷方式

20 Intent.ACTION_PICK_ACTIVITY

選擇一個activity,返回被選擇的activity的類名

21 Intent.ACTION_ SEARCH

執行搜索

22 Intent.ACTION_SYC

執行數據同步

相關文章
相關標籤/搜索