安卓中一句代碼,解決撥號,定位,網頁,卸載,安裝,播放,郵件,簡訊

來源:互聯網
上載者:User

標籤:android   style   blog   http   color   os   io   檔案   for   

//以下是常用到的Intent的URI及其樣本,包含了大部分應用中用到的共用Intent。  002    003 //一、開啟一個網頁,類別是Intent.ACTION_VIEW  004    005 Uri uri = Uri.parse(“http://blog.3gstdy.com/”);  006    007 Intent intent = new Intent(Intent.ACTION_VIEW, uri);  008 //二、開啟地圖並定位到一個點  009    010 Uri uri = Uri.parse(“geo:52.76,-79.0342″);  011    012 Intent intent = new Intent(Intent.ACTION_VIEW, uri);  013    014 //三、開啟撥號介面 ,類型是Intent.ACTION_DIAL  015    016 Uri uri = Uri.parse(“tel:10086″);  017    018 Intent intent = new Intent(Intent.ACTION_DIAL, uri);  019    020 //四、直接撥打到電話,與三不同的是,這個直接撥打到電話,而不是開啟撥號介面  021    022 Uri uri = Uri.parse(“tel:10086″);  023    024 Intent intent = new Intent(Intent.ACTION_CALL, uri);  025    026 //五、卸載一個應用,Intent的類別是Intent.ACTION_DELETE  027    028 Uri uri = Uri.fromParts(“package”, “xxx”, null);  029    030 Intent intent = new Intent(Intent.ACTION_DELETE, uri);  031    032 //六、安裝應用程式,Intent的類別是Intent.ACTION_PACKAGE_ADDED  033    034 Uri uri = Uri.fromParts(“package”, “xxx”, null);  035    036 Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);  037    038 //七、播放音頻檔案  039    040 Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″);  041    042 Intent intent = new Intent(Intent.ACTION_VIEW, uri);  043    044 intent.setType(“audio/mp3″);  045    046 //八、開啟發郵件介面  047    048 Uri uri= Uri.parse(“mailto:[email protected]”);  049    050 Intent intent = new Intent(Intent.ACTION_SENDTO, uri);  051    052 //九、發郵件,與八不同這裡是將郵件發送出去,  053    054 Intent intent = new Intent(Intent.ACTION_SEND);  055    056 String[] tos = { “[email protected]” };  057    058 String[] ccs = { “[email protected]” };  059    060 intent.putExtra(Intent.EXTRA_EMAIL, tos);  061    062 intent.putExtra(Intent.EXTRA_CC, ccs);  063    064 intent.putExtra(Intent.EXTRA_TEXT, “I come from http://blog.3gstdy.com”);  065    066 intent.putExtra(Intent.EXTRA_SUBJECT, “http://blog.3gstdy.com”);intent.setType(“message/rfc882″);  067    068 Intent.createChooser(intent, “Choose Email Client”);  069    070 //發送帶附件的郵件  071    072 Intent intent = new Intent(Intent.ACTION_SEND);  073    074 intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);  075    076 intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);  077    078 intent.setType(“audio/mp3″);  079    080 startActivity(Intent.createChooser(intent, “Choose Email Client”));  081    082 //十、發簡訊  083    084 Uri uri= Uri.parse(“tel:10086″);  085    086 Intent intent = new Intent(Intent.ACTION_VIEW, uri);  087    088 intent.putExtra(“sms_body”, “I come from http://blog.3gstdy.com”);  089    090 intent.setType(“vnd.Android-dir/mms-sms”);  091    092 //十一、直接發郵件  093    094 Uri uri= Uri.parse(“smsto://100861″);  095    096 Intent intent = new Intent(Intent.ACTION_SENDTO, uri);  097    098 intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”);  099    100 //十二、發多媒體訊息  101    102 Uri uri= Uri.parse(“content://media/external/images/media/23″);  103    104 Intent intent = new Intent(Intent.ACTION_SEND);  105    106 intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”);  107    108 intent.putExtra(Intent.EXTRA_STREAM, uri);  109    110 intent.setType(“image/png”);  111    112 //十三、# Market 相關  113    114 //1 //尋找某個應用  115    116 Uri uri = Uri.parse(“market://search?q=pname:pkg_name”);  117    118 Intent it = new Intent(Intent.ACTION_VIEW, uri);  119    120 startActivity(it);  121    122 //where pkg_name is the full package path for an application  123    124 //2 //顯示某個應用的相關資訊  125    126 Uri uri = Uri.parse(“market://details?id=app_id”);  127    128 Intent it = new Intent(Intent.ACTION_VIEW, uri);  129    130 startActivity(it);  131    132 //where app_id is the application ID, find the ID  133    134 //by clicking on your application on Market home  135    136 //page, and notice the ID from the address bar  137    138 //十四、路徑規劃  139    140 Uri uri = Uri.parse(“http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);  141    142 Intent it = new Intent(Intent.ACTION_VIEW, uri);  143    144 startActivity(it); 

安卓中一句代碼,解決撥號,定位,網頁,卸載,安裝,播放,郵件,簡訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.