android教程之intent的action屬性使用示例(intent發(fā)短信)
Action :規(guī)定了Intent要完成的動(dòng)作,是一個(gè)字符串常量。使用setAction()來設(shè)置Action屬性,使用getAction()來獲得Action屬性。既可以使用系統(tǒng)內(nèi)置的Action,也可以自己定義。系統(tǒng)自定義的action,如ACTION_VIEW, ACTION_EDIT, ACTION_MAIN等等。
1.自定義Action
在“目的Activity”的AndroidManifest.xml中指定action常量。
<activity android:name=".ActionDestination">
<intent-filter>
<action android:name="Skywang_ACTION" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<categoryandroid:name="android.intent.category.DEFAULT" />的作用是用來說明,可以通過隱式跳轉(zhuǎn)(即其它類調(diào)用setAction("Skywang_ACTION"))來找到ActionDestination這個(gè)activity。這樣,其它的類就可以通過下面的代碼跳轉(zhuǎn)到ActionDestination。跳轉(zhuǎn)時(shí),setAction的字符串"Skywang_ACTION"必須與AndroidManifest.xml中定義的"Skywang_ACTION"一致。
Intent intent = new Intent();
intent.setAction("Skywang_ACTION");
startActivity(intent);
2系統(tǒng)Action
// 流量網(wǎng)頁
Uri uri =Uri.parse("http://www.baidu.com");
Intent intent = newIntent(Intent.ACTION_VIEW, uri);
startActivity(intent);
// 撥打電話
// if you want to use ACTION_DIAL, you mustadd permissin in manifest, the permission is bellow
// <uses-permissionandroid:name="android.permission.CALL_PHONE" />
Uri uri = Uri.parse("tel:12580");
Intent it = new Intent(Intent.ACTION_DIAL,uri);
startActivity(it);
// 發(fā)送短信
Uri uri = Uri.parse("smsto:13410177756");
Intent it = newIntent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "TheSMS text");
startActivity(it);
//播放mp3
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri =Uri.parse("file:///sdcard/song.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);
- Android使用Intent.ACTION_SEND分享圖片和文字內(nèi)容的示例代碼
- Android編程實(shí)現(xiàn)自定義分享列表ACTION_SEND功能的方法
- android中Intent傳值與Bundle傳值的區(qū)別詳解
- android中intent傳遞list或者對(duì)象的方法
- Android Intent的幾種用法詳細(xì)解析
- Android 廣播大全 Intent Action 事件詳解
- 詳解Android中IntentService的使用方法
- Android中使用IntentService創(chuàng)建后臺(tái)服務(wù)實(shí)例
- Android利用Intent.ACTION_SEND進(jìn)行分享
相關(guān)文章
Android?雙屏異顯自適應(yīng)Dialog的實(shí)現(xiàn)
Android 多屏互聯(lián)的時(shí)代,必然會(huì)出現(xiàn)多屏連接的問題,本文主要介紹了Android?雙屏異顯自適應(yīng)Dialog的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2023-12-12Android實(shí)現(xiàn)類似3D Touch菜單功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)類似3D Touch菜單功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03Android中解決EditText放到popupWindow中,原有復(fù)制、粘貼、全選、選擇功能失效問題
這篇文章主要介紹了Android中解決EditText放到popupWindow中,原有復(fù)制、粘貼、全選、選擇功能失效問題 的相關(guān)資料,需要的朋友可以參考下2016-04-04Android自定義PopWindow帶動(dòng)畫向下彈出效果
這篇文章主要為大家詳細(xì)介紹了Android自定義PopWindow帶動(dòng)畫向下彈出效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11初學(xué)Android之網(wǎng)絡(luò)封裝實(shí)例
大家好,本篇文章主要講的是初學(xué)Android之網(wǎng)絡(luò)封裝實(shí)例,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12Android開發(fā)中如何解決Fragment +Viewpager滑動(dòng)頁面重復(fù)加載的問題
這篇文章主要介紹了Android開發(fā)中如何解決Fragment +Viewpager滑動(dòng)頁面重復(fù)加載的問題 ,需要的朋友可以參考下2017-07-07Android自定義View實(shí)現(xiàn)照片裁剪框與照片裁剪功能
這篇文章主要介紹了Android自定義View實(shí)現(xiàn)照片裁剪框與照片裁剪功能的相關(guān)資料,需要的朋友可以參考下2016-07-07Android應(yīng)用中clearFocus方法調(diào)用無效的問題解決
clearFocus()主要用于清除EditText的焦點(diǎn),Android App開發(fā)中很多時(shí)候會(huì)發(fā)現(xiàn)其調(diào)用無效,帶著這個(gè)問題我們就來看一下本文主題、Android應(yīng)用中clearFocus方法調(diào)用無效的問題解決2016-05-05Android編程出現(xiàn)Button點(diǎn)擊事件無效的解決方法示例
這篇文章主要介紹了Android編程出現(xiàn)Button點(diǎn)擊事件無效的解決方法,結(jié)合實(shí)例形式分析了Android編程中出現(xiàn)Button點(diǎn)擊事件無效的原因及相關(guān)的解決方法,需要的朋友可以參考下2018-02-02