安卓中一句代码,解决拨号,定位,网页,卸载,安装,播放,邮件,短信

智者不为愚者谋,勇者不为怯者死。这篇文章主要讲述安卓中一句代码,解决拨号,定位,网页,卸载,安装,播放,邮件,短信相关的知识,希望能为你提供帮助。

//下面是经常使用到的Intent的URI及其演示样例,包括了大部分应用中用到的共用Intent。002003 //一、打开一个网页,类别是Intent.ACTION_VIEW004005 Uri uri = Uri.parse(“http://blog.3gstdy.com/”); 006007 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 008 //二、打开地图并定位到一个点009010 Uri uri = Uri.parse(“geo:52.76,-79.0342″); 011012 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 013014 //三、打开拨号界面 ,类型是Intent.ACTION_DIAL015016 Uri uri = Uri.parse(“tel:10086″); 017018 Intent intent = new Intent(Intent.ACTION_DIAL, uri); 019020 //四、直接拨打电话,与三不同的是,这个直接拨打电话。而不是打开拨号界面021022 Uri uri = Uri.parse(“tel:10086″); 023024 Intent intent = new Intent(Intent.ACTION_CALL, uri); 025026 //五、卸载一个应用,Intent的类别是Intent.ACTION_DELETE027028 Uri uri = Uri.fromParts(“package”, “xxx”, null); 029030 Intent intent = new Intent(Intent.ACTION_DELETE, uri); 031032 //六、安装应用程序,Intent的类别是Intent.ACTION_PACKAGE_ADDED033034 Uri uri = Uri.fromParts(“package”, “xxx”, null); 035036 Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri); 037038 //七、播放音频文件039040 Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″); 041042 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 043044 intent.setType(“audio/mp3″); 045046 //八、打开发邮件界面047048 Uri uri= Uri.parse(“mailto:[email  protected]”); 049050 Intent intent = new Intent(Intent.ACTION_SENDTO, uri); 051052 //九、发邮件,与八不同这里是将邮件发送出去,053054 Intent intent = new Intent(Intent.ACTION_SEND); 055056 String[] tos = { “[email  protected]” }; 057058 String[] ccs = { “[email  protected]” }; 059060 intent.putExtra(Intent.EXTRA_EMAIL, tos); 061062 intent.putExtra(Intent.EXTRA_CC, ccs); 063064 intent.putExtra(Intent.EXTRA_TEXT, “I come from http://blog.3gstdy.com”); 065066 intent.putExtra(Intent.EXTRA_SUBJECT, “http://blog.3gstdy.com”); intent.setType(“message/rfc882″); 067068 Intent.createChooser(intent, “Choose Email Client”); 069070 //发送带附件的邮件071072 Intent intent = new Intent(Intent.ACTION_SEND); 073074 intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”); 075076 intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″); 077078 intent.setType(“audio/mp3″); 079080 startActivity(Intent.createChooser(intent, “Choose Email Client”)); 081082 //十、发短信083084 Uri uri= Uri.parse(“tel:10086″); 085086 Intent intent = new Intent(Intent.ACTION_VIEW, uri); 087088 intent.putExtra(“sms_body”, “I come from http://blog.3gstdy.com”); 089090 intent.setType(“vnd.android-dir/mms-sms”); 091092 //十一、直接发邮件093094 Uri uri= Uri.parse(“smsto://100861″); 095096 Intent intent = new Intent(Intent.ACTION_SENDTO, uri); 097098 intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”); 099100 //十二、发彩信101102 Uri uri= Uri.parse(“content://media/external/images/media/23″); 103104 Intent intent = new Intent(Intent.ACTION_SEND); 105106 intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”); 107108 intent.putExtra(Intent.EXTRA_STREAM, uri); 109110 intent.setType(“image/png”); 111112 //十三、# Market 相关113114 //1 //寻找某个应用115116 Uri uri = Uri.parse(“market://search?
q=pname:pkg_name”); 117118 Intent it = new Intent(Intent.ACTION_VIEW, uri); 119120 startActivity(it); 121122 //where pkg_name is the full package path for an application123124 //2 //显示某个应用的相关信息125126 Uri uri = Uri.parse(“market://details?
【安卓中一句代码,解决拨号,定位,网页,卸载,安装,播放,邮件,短信】id=app_id”); 127128 Intent it = new Intent(Intent.ACTION_VIEW, uri); 129130 startActivity(it); 131132 //where app_id is the application ID, find the ID133134 //by clicking on your application on Market home135136 //page, and notice the ID from the address bar137138 //十四、路径规划139140 Uri uri = Uri.parse(“http://maps.google.com/maps?f=d& saddr=startLat%20startLng& daddr=endLat%20endLng& hl=en”); 141142 Intent it = new Intent(Intent.ACTION_VIEW, uri); 143144 startActivity(it);



    推荐阅读