Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1542705
  • 博文数量: 237
  • 博客积分: 5139
  • 博客等级: 大校
  • 技术积分: 2751
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 14:48
文章分类

全部博文(237)

文章存档

2016年(1)

2012年(4)

2011年(120)

2010年(36)

2009年(64)

2008年(12)

分类: 嵌入式

2011-06-30 16:02:19

转自:
以下是eoe为大家总结的常用到的Intent的URI及其示例,包含了大部分应用中用到的共用Intent。

一、打开一个网页,类别是Intent.ACTION_VIEW

Java代码:
  1. Uri uri = Uri.parse(“http://blog.3gstdy.com/”);  
  2. nt intent = new Intent(Intent.ACTION_VIEW, uri);  
复制代码
二、打开地图并定位到一个点

Java代码:
  1. Uri uri = Uri.parse(“geo:52.76,-79.0342″);  
  2. Intent intent = new Intent(Intent.ACTION_VIEW, uri);
复制代码
三、打开拨号界面 ,类型是Intent.ACTION_DIAL

Java代码:
  1. Uri uri = Uri.parse(“tel:10086″);  
  2. Intent intent = new Intent(Intent.ACTION_DIAL, uri);  
复制代码
四、直接拨打电话,与三不同的是,这个直接拨打电话,而不是打开拨号界面

Java代码:
  1. Uri uri = Uri.parse(“tel:10086″);  
  2. Intent intent = new Intent(Intent.ACTION_CALL, uri);  
复制代码
五、卸载一个应用,Intent的类别是Intent.ACTION_DELETE

Java代码:
  1. Uri uri = Uri.fromParts(“package”, “xxx”, null);  
  2. Intent intent = new Intent(Intent.ACTION_DELETE, uri);
复制代码
六、安装应用程序,Intent的类别是Intent.ACTION_PACKAGE_ADDED

Java代码:
  1. Uri uri = Uri.fromParts(“package”, “xxx”, null);  
  2. Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);
复制代码
七、播放音频文件

Java代码:
  1. Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″);  
  2. Intent intent = new Intent(Intent.ACTION_VIEW, uri);  
  3. intent.setType(“audio/mp3″);  
复制代码
八、打开发邮件界面

Java代码:
  1. Uri uri= Uri.parse(“mailto:admin@3gstdy.com”);  
  2. Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
复制代码
九、发邮件,与八不同这里是将邮件发送出去

Java代码:
  1. Intent intent = new Intent(Intent.ACTION_SEND);  
  2.   String[] tos = {  
  3. 9Cadmin@3gstdy.com" target="_blank">“admin@3gstdy.com” };
  4.   String[] ccs = {
  5. 9Cwebmaster@3gstdy.com" target="_blank">“webmaster@3gstdy.com” };  
  6.   intent.putExtra(Intent.EXTRA_EMAIL, tos);  
  7.   intent.putExtra(Intent.EXTRA_CC, ccs);  
  8.   intent.putExtra(Intent.EXTRA_TEXT, “I come from  
  9. http://blog.3gstdy.com”);  
  10.   intent.putExtra(Intent.EXTRA_SUBJECT, “http://blog.3gstdy.com”);intent.setType

  11. (“message/rfc882″);  
  12.   Intent.createChooser(intent, “Choose Email Client”);  
  13.   //发送带附件的邮件  
  14.   Intent intent = new Intent(Intent.ACTION_SEND);  
  15.   intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);  
  16.   intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);  
  17.   intent.setType(“audio/mp3″);  
  18.   startActivity(Intent.createChooser(intent, “Choose Email Client”))
复制代码
十、发短信

Java代码:
  1. Uri uri= Uri.parse(“tel:10086″);  
  2. Intent intent = new Intent(Intent.ACTION_VIEW, uri);  
  3. intent.putExtra(“sms_body”, “I come from  
  4. tp://blog.3gstdy.com”);  
  5. intent.setType(“vnd.Android-dir/mms-sms”);  
复制代码
十一、直接发邮件

Java代码:
  1. Uri uri= Uri.parse(“smsto://100861″);  
  2. Intent intent = new Intent(Intent.ACTION_SENDTO, uri);  
  3. intent.putExtra(“sms_body”, “3g android  
  4. tp://blog.3gstdy.com”);  
复制代码
十二、发彩信

Java代码:
  1. Uri uri= Uri.parse(“content://media/external/images/media/23″);  
  2. Intent intent = new Intent(Intent.ACTION_SEND);  
  3. intent.putExtra(“sms_body”, “3g android  
  4. tp://blog.3gstdy.com”);  
  5. intent.putExtra(Intent.EXTRA_STREAM, uri);  
  6. intent.setType(“image/png”);  
复制代码
十三、# Market 相关

Java代码:
  1. 1 //寻找某个应用  
  2. Uri uri = Uri.parse(“market://search?q=pname:pkg_name”);  
  3. Intent it = new Intent(Intent.ACTION_VIEW, uri);  
  4. startActivity(it);  
  5. //where pkg_name is the full package path for an application  
  6. 2 //显示某个应用的相关信息  
  7. Uri uri = Uri.parse(“market://details?id=app_id”);  
  8. Intent it = new Intent(Intent.ACTION_VIEW, uri);  
  9. startActivity(it);  
  10. //where app_id is the application ID, find the ID  
  11. //by clicking on your application on Market home  
  12. //page, and notice the ID from the address bar  
复制代码
十四、路径规划

Java代码:
  1. Uri uri = Uri.parse(“%20startLng&daddr=endLat%20endLng&hl=en”);  
  2. Intent it = new Intent(Intent.ACTION_VIEW, uri);  
  3. startActivity(it);
复制代码
阅读(682) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~