zoukankan      html  css  js  c++  java
  • 安卓中一句代码,解决拨号,定位,网页,卸载,安装,播放,邮件,短信

    //下面是经常使用到的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:admin@3gstdy.com”);  
    
    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 = { “admin@3gstdy.com” };  
    
    057    
    
    058 String[] ccs = { “webmaster@3gstdy.com” };  
    
    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);

  • 相关阅读:
    HDU 5059 Help him
    HDU 5058 So easy
    HDU 5056 Boring count
    HDU 5055 Bob and math problem
    HDU 5054 Alice and Bob
    HDU 5019 Revenge of GCD
    HDU 5018 Revenge of Fibonacci
    HDU 1556 Color the ball
    CodeForces 702D Road to Post Office
    CodeForces 702C Cellular Network
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/7253670.html
Copyright © 2011-2022 走看看