a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統 > Android > 正文

Android開發中Intent.Action各種常見的作用匯總

2019-10-21 21:33:42
字體:
來源:轉載
供稿:網友

本文介紹Android中Intent的各種常見作用。

1 Intent.ACTION_MAIN

String: android.intent.action.MAIN

標識Activity為一個程序的開始。比較常用。

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

呼叫指定的電話號碼。

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

Output:Nothing 

Intent intent=new Intent(); intent.setAction(Intent.ACTION_CALL);  intent.setData(Uri.parse("tel:1320010001");startActivity(intent);

使用Intent.ACTION_CALL時,必須在AndroidManifest.xml中添加<uses-permission android:name="android.permission.CALL_PHONE" />已獲取撥打電話的權限。Intent.ACTION_CALL與Intent.ACTION_DIALOG不同,Intent.ACTION_DIALOG只是調用撥號鍵盤,將電話號碼復制上去,而Intent.ACTION_CALL則是直接撥打電話

3 Intent.Action.DIAL

String: action.intent.action.DIAL

調用撥號面板

Intent intent=new Intent();intent.setAction(Intent.ACTION_DIAL);  //android.intent.action.DIALintent.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_GET_CONTENT

//選擇圖片 requestCode 返回的標識Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"intent.setType(contentType); //查看類型 String IMAGE_UNSPECIFIED = "image/*";Intent wrapperIntent = Intent.createChooser(intent, null);((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//添加音頻Intent intent = new Intent(Intent.ACTION_GET_CONTENT);intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";Intent wrapperIntent = Intent.createChooser(intent, null);((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//拍攝視頻 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.ACTION_GET_CONTENT);intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";Intent wrapperIntent = Intent.createChooser(intent, null);((Activity) context).startActivityForResult(wrapperIntent, requestCode); 
//錄音Intent intent = new Intent(Intent.ACTION_GET_CONTENT);intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";intent.setClassName("com.android.soundrecorder","com.android.soundrecorder.SoundRecorder");((Activity) context).startActivityForResult(intent, requestCode); 
//拍照 REQUEST_CODE_TAKE_PICTURE 為返回的標識Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); 

完畢。^_^

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VEVB武林網的支持。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 久久精品一区二区三区四区 | 日韩欧美国产网站 | 偷拍自拍亚洲 | 国产一区二区三区免费在线观看 | 免费福利视频一区 | 91精品午夜 | 欧美国产激情二区三区 | 99国产精品99久久久久久 | 在线免费观看一区 | 国产精品一区网站 | 久久亚洲国产视频 | 欧美一级小视频 | 97超碰在线播放 | 国产成人久久精品77777 | 免费av一区二区三区 | 国产片三级91 | 欧美天堂在线 | 久久激情综合 | 欧美成人一区二区三区片免费 | 成人精品一区二区三区中文字幕 | 国产二区视频 | 婷婷激情综合 | 日韩视频一区二区 | 日韩www| 亚洲成av人片在线观看 | 日韩视频久久 | 蜜桃视频在线播放 | 一级毛片视频 | 男人的天堂在线视频 | 国产一级片一区二区三区 | 欧美天堂在线观看 | 91九色在线观看 | 日本不卡在线 | 青青草免费在线 | 国产精品久久久久久久久久99 | 久久精品99| 久久人人爽人人爽 | 成人欧美一区二区三区黑人孕妇 | 日韩视频在线免费 | 日韩一区二区黄色片 | 日韩和的一区二区 |