Intent中各种常见的Action
1?Intent.ACTION_MAIN
?
String:?android.intent.action.MAIN?
標(biāo)識(shí)
Activity
為一個(gè)程序的開(kāi)始。比較常用。
?
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?
呼叫指定的電話號(hào)碼。
?
Input:
電話號(hào)碼。數(shù)據(jù)格式為:
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?
調(diào)用撥號(hào)面板
?
Intent?intent=new?Intent();?
intent.setAction(Intent.ACTION_DIAL);??
//android.intent.action.DIAL?
intent.setData(Uri.parse("tel:1320010001");?
startActivity(intent);??
?
?
Input:
電話號(hào)碼。數(shù)據(jù)格式為:
tel:+phone?number??
Output:Nothing?
說(shuō)明:打開(kāi)
Android
的撥號(hào)
UI
。如果沒(méi)有設(shè)置數(shù)據(jù),則打開(kāi)一個(gè)空的
UI
,如果
設(shè)置數(shù)據(jù),
action.DIAL
則通過(guò)調(diào)用
getData()
獲取電話號(hào)碼。
?
但設(shè)置電話號(hào)碼的數(shù)據(jù)格式為
?tel:+phone?number.??
4?Intent.Action.ALL_APPS
?
String:?andriod.intent.action.ALL_APPS?
列出所有的應(yīng)用。
?
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?
別用于指定一些數(shù)據(jù)應(yīng)該附屬于一些其他的地方,
例如,
圖片數(shù)據(jù)應(yīng)該附屬于聯(lián)
系人
??
Input:?Data?
Output:nothing?
7?Intent.ACTION_BUG_REPORT
?
String:?android.intent.action.BUG_REPORT?
顯示
Dug
報(bào)告。
?
Input:nothing?
output:nothing?
8?Intent.Action_CALL_BUTTON
?
String:?android.action.intent.CALL_BUTTON.?
相當(dāng)于用戶按下“撥號(hào)”鍵。經(jīng)測(cè)試顯示的是“通話記錄”
?
Input:nothing?
Output:nothing?
Intent?intent?=?new?
Intent(Intent.ACTION_CALL_BUTTON);startActivity(intent);??
9?Intent.ACTION_CHOOSER
?
String:?android.intent.action.CHOOSER?
顯示一個(gè)
activity
選擇器,
允許用戶在進(jìn)程之前選擇他們想要的
,
與之對(duì)應(yīng)的是
Intent.ACTION_GET_CONTENT.?
10.?Intent.ACTION_GET_CONTENT
?
String:?android.intent.action.GET_CONTENT?
允許用戶選擇特殊種類的數(shù)據(jù),
并返回
(特殊種類的數(shù)據(jù):
照一張相片或錄一段
音)
??
Input:?Type?
Output:URI?
int?requestCode?=?1001;Intent?intent?=?new?
Intent(Intent.ACTION_GET_CONTENT);?//?
"android.intent.action.GET_CONTENT"?
intent.setType("p_w_picpath/*");?
//?
查看類型,如果是其他類型,比如視頻則替換
成
?video/*
,或
?*/*?
Intent?wrapperIntent?=?Intent.createChooser(intent,?null);??
startActivityForResult(wrapperIntent,?requestCode);??
?
11?Intent.ACTION_VIEW?
?
String?android.intent.action.VIEW??
用于顯示用戶的數(shù)據(jù)。
?
比較通用,會(huì)根據(jù)用戶的數(shù)據(jù)類型打開(kāi)相應(yīng)的
Activity
。
?
比如
?tel:13400010001
打開(kāi)撥號(hào)程序,
http://www.g.cn
則會(huì)打開(kāi)瀏覽器等。
?
Uri?uri?=?Uri.parse("http://www.google.com");?//
瀏覽器
?Uri?uri?
=Uri.parse("tel:1232333");?//
撥號(hào)程序
??
Uri?uri=Uri.parse("geo:39.899533,116.036476");?//
打開(kāi)地圖定位
??
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);?
//
調(diào)用發(fā)送短信的程序
??
Intent?it?=?new?Intent(Intent.ACTION_VIEW);?
it.putExtra("sms_body",?"
信息內(nèi)容
...");??
it.setType("vnd.android-dir/mms-sms");??
startActivity(it);??
12?Intent.ACTION_SENDTO?
?
String:?android.intent.action.SENDTO?
說(shuō)明:發(fā)送短信息
??
//
發(fā)送短信息
?Uri?uri?=?Uri.parse("smsto:13200100001");??
Intent?it?=?new?Intent(Intent.ACTION_SENDTO,?uri);??
it.putExtra("sms_body",?"
信息內(nèi)容
...");??
startActivity(it);??
//
發(fā)送彩信
,
設(shè)備會(huì)提示選擇合適的程序發(fā)送
?Uri?uri?=?
Uri.parse("content://media/external/p_w_picpaths/media/23");??
//
設(shè)備中的資源(圖像或其他資源)
??
Intent?intent?=?new?Intent(Intent.ACTION_SEND);??
intent.putExtra("sms_body",?"
內(nèi)容
");??
intent.putExtra(Intent.EXTRA_STREAM,?uri);??
intent.setType("p_w_picpath/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?
為指定的數(shù)據(jù)顯示可編輯界面
?
14?Intent.ACTION_PICK?
從數(shù)據(jù)中選擇一個(gè)項(xiàng)目(
item
),將被選中的項(xiàng)目返回
?
15?Intent.ACTION_SEND?
給別人提供一些數(shù)據(jù)
?
16?Intent.ACTION_DELETE?
從容器中刪除給定的數(shù)據(jù)
?
17?Intent.ACTION_INSERT?
在容器中插入一個(gè)空項(xiàng)目(
item
)
?
18?Intent.ACTION_RUN?
運(yùn)行數(shù)據(jù)(指定的應(yīng)用),無(wú)論它(應(yīng)用)是什么
?
19?Intent.
?
EXTRA_INTENT?
附加數(shù)據(jù):和
ACTION_PICK_ACTIVITY
一起使用時(shí),說(shuō)明用戶選擇的用來(lái)顯示的
activity
;和
ACTION_ADD_SHORTCUT
一起使用時(shí),描述要添加的快捷方式
?
20?Intent.ACTION_PICK_ACTIVITY?
選擇一個(gè)
activity
,返回被選擇的
activity
的類名
?
21?Intent.ACTION_?SEARCH?
執(zhí)行搜索
?
?
轉(zhuǎn)載于:https://blog.51cto.com/jinchao/1592111
總結(jié)
以上是生活随笔為你收集整理的Intent中各种常见的Action的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 自己动手之使用反射和泛型,动态读取XML
- 下一篇: java解析纯真IP数据库