最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2018年12月13日 11:02:59   作者:franksight  
今天小編就為大家分享一篇關于Android開發(fā)中Intent.Action各種常見的作用匯總,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

本文介紹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.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);
//調用發(fā)送短信的程序 
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 

說明:發(fā)送短信息

//發(fā)送短信息 
Uri uri = Uri.parse("smsto:13200100001"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
it.putExtra("sms_body", "信息內容..."); 
startActivity(it); 
//發(fā)送彩信,設備會提示選擇合適的程序發(fā)送 
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); 

完畢。^_^

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接

相關文章

  • Android studio 實現手機掃描二維碼功能

    Android studio 實現手機掃描二維碼功能

    這篇文章主要介紹了Android studio 實現手機掃描二維碼功能,需要的朋友可以參考下
    2019-10-10
  • Android之高德地圖定位SDK集成及地圖功能實現

    Android之高德地圖定位SDK集成及地圖功能實現

    本文主要介紹了Android中高德地圖定位SDK集成及地圖功能的實現。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • Android編程布局(Layout)之AbsoluteLayout用法實例分析

    Android編程布局(Layout)之AbsoluteLayout用法實例分析

    這篇文章主要介紹了Android編程布局(Layout)之AbsoluteLayout用法,結合實例形式簡單分析了Android絕對布局AbsoluteLayout的實現方法,需要的朋友可以參考下
    2015-12-12
  • 在Kotlin開發(fā)中如何使用集合詳解

    在Kotlin開發(fā)中如何使用集合詳解

    這篇文章主要給大家介紹了關于在Kotlin開發(fā)中如何使用集合的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2018-03-03
  • Flutter實現牛頓擺動畫效果的示例代碼

    Flutter實現牛頓擺動畫效果的示例代碼

    牛頓擺大家應該都不陌生,也叫碰碰球、永動球(理論情況下),那么今天我們用Flutter實現這么一個理論中的永動球,可以作為加載Loading使用,需要的可以參考一下
    2022-04-04
  • Android 圖片顯示與屏幕適配的問題

    Android 圖片顯示與屏幕適配的問題

    這篇文章主要介紹了Android 圖片顯示與屏幕適配的問題的相關資料,Android的分辨率問題是每個Android 開發(fā)者頭疼的問題,那么這里給大家介紹個萬能辦法,需要的朋友可以參考下
    2017-08-08
  • Android安裝應用 INSTALL_FAILED_DEXOPT 問題及解決辦法

    Android安裝應用 INSTALL_FAILED_DEXOPT 問題及解決辦法

    這篇文章主要介紹了Android安裝應用 INSTALL_FAILED_DEXOPT 解決辦法,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-04-04
  • Android事件分發(fā)機制的詳解

    Android事件分發(fā)機制的詳解

    這篇文章主要介紹了Android事件分發(fā)機制的詳解的相關資料,希望通過本文能幫助到大家,讓大家理解掌握Android事件分發(fā)機制,需要的朋友可以參考下
    2017-09-09
  • Android實現讀取掃碼槍內容(條形碼)

    Android實現讀取掃碼槍內容(條形碼)

    這篇文章主要為大家詳細介紹了Android實現讀取掃碼槍內容、條形碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Android中Activity生命周期和啟動模式詳解

    Android中Activity生命周期和啟動模式詳解

    這篇文章主要介紹了Activity生命周期和啟動模式詳解的相關資料,需要的朋友可以參考下
    2016-07-07

最新評論

晴隆县| 沙河市| 阿拉尔市| 三门峡市| 满城县| 清镇市| 左云县| 达州市| 泗阳县| 郸城县| 新源县| 渑池县| 太保市| 出国| 利津县| 绥德县| 东光县| 西峡县| 昌乐县| 西充县| 彭阳县| 昌平区| 泽库县| 墨竹工卡县| 康定县| 雅安市| 甘南县| 漳州市| 迁西县| 顺义区| 义乌市| 略阳县| 壤塘县| 莱州市| 玛纳斯县| 镇巴县| 金寨县| 鹿泉市| 比如县| 罗定市| 翁牛特旗|