麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 系統(tǒng) > Android > 正文

Android Intent的幾種用法詳細(xì)解析

2020-04-11 11:56:37
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Intent應(yīng)該算是Android中特有的東西。你可以在Intent中指定程序要執(zhí)行的動(dòng)作(比如:view,edit,dial),以及程序執(zhí)行到該動(dòng)作時(shí)所需要的資料。都指定好后,只要調(diào)用startActivity(),Android系統(tǒng)會(huì)自動(dòng)尋找最符合你指定要求的應(yīng)用程序,并執(zhí)行該程序。

下面列出幾種Intent的用法
顯示網(wǎng)頁(yè):

復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("http://www.google.com");
Intent it  = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);

顯示地圖:
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);

路徑規(guī)劃:
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
Intent it = new Intent(Intent.ACTION_VIEW,URI);
startActivity(it);

撥打電話:
調(diào)用撥號(hào)程序
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("tel:xxxxxx");
Intent it = new Intent(Intent.ACTION_DIAL, uri); 
startActivity(it); 
Uri uri = Uri.parse("tel.xxxxxx");
Intent it =new Intent(Intent.ACTION_CALL,uri);

要使用這個(gè)必須在配置文件中加入<uses-permission id="android.permission.CALL_PHONE" />
發(fā)送SMS/MMS
調(diào)用發(fā)送短信的程序
復(fù)制代碼 代碼如下:

Intent it = new Intent(Intent.ACTION_VIEW);  
it.putExtra("sms_body", "The SMS text");  
it.setType("vnd.android-dir/mms-sms");  
startActivity(it); 

發(fā)送短信
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("smsto:0800000123");  
Intent it = new Intent(Intent.ACTION_SENDTO, uri);  
it.putExtra("sms_body", "The SMS text");  
startActivity(it); 

發(fā)送彩信
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("content://media/external/images/media/23");  
Intent it = new Intent(Intent.ACTION_SEND);  
it.putExtra("sms_body", "some text");  
it.putExtra(Intent.EXTRA_STREAM, uri);  
it.setType("image/png");  
startActivity(it);

發(fā)送Email
復(fù)制代碼 代碼如下:

Uri uri = Uri.parse("mailto:[email protected]");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it = new Intent(Intent.ACTION_SEND);  
it.putExtra(Intent.EXTRA_EMAIL, "[email protected]");  
it.putExtra(Intent.EXTRA_TEXT, "The email body text");  
it.setType("text/plain");  
startActivity(Intent.createChooser(it, "Choose Email Client")); 
Intent it=new Intent(Intent.ACTION_SEND);    
String[] tos={"[email protected]"};    
String[] ccs={"[email protected]"};    
it.putExtra(Intent.EXTRA_EMAIL, tos);    
it.putExtra(Intent.EXTRA_CC, ccs);    
it.putExtra(Intent.EXTRA_TEXT, "The email body text");    
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");    
it.setType("message/rfc822");    
startActivity(Intent.createChooser(it, "Choose Email Client")); 

添加附件
復(fù)制代碼 代碼如下:

Intent it = new Intent(Intent.ACTION_SEND);  
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");  
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");  
sendIntent.setType("audio/mp3");  
startActivity(Intent.createChooser(it, "Choose Email Client"));

播放多媒體
復(fù)制代碼 代碼如下:
 
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/song.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");  
Intent it = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(it); 

Uninstall 程序
復(fù)制代碼 代碼如下:

Uri uri = Uri.fromParts("package", strPackageName, null);  
Intent it = new Intent(Intent.ACTION_DELETE, uri);  
startActivity(it);

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 欧美a级大胆视频 | 91香草视频 | 成年免费网站 | 久久艹国产精品 | va视频| 春光影院理论片 | 激情网站视频 | 国语自产免费精品视频在 | 斗破苍穹在线免费 | 久久久久免费电影 | chinesegv男男猛男无套 | 免费男女视频 | 精品国产一区二区三区四区在线 | 久久精品在线免费观看 | 毛片国产 | 国产精品免费看 | 激情宗合网 | 免费毛片随便看 | 久久久久久久久久久国产精品 | 黄色毛片免费视频 | 黄污网址 | 亚洲国产精品99 | 99久久婷婷国产综合精品青牛牛 | 成人午夜免费看 | 91av在线免费观看 | av日韩一区二区 | 欧美黑人伦理 | 中文字幕观看 | 久久精品亚洲成在人线av网址 | 国产精品视频 | 亚洲综人网 | 亚洲成人激情av | 大西瓜永久免费av在线 | 久久久成人999亚洲区美女 | 国内性爱视频 | 国产一级aaa全黄毛片 | 日本高清在线播放 | 一区二区三区视频在线 | 成人福利软件 | 日本不卡一区二区三区在线观看 | 欧美 日韩 三区 |