打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Intent.ACTION_VIEW
 
 

 


1 Intent.ACTION_VIEW

String android.intent.action.VIEW

用于显示用户的数据。比较通用,会根据用户的数据类型打开相应的Activity。比如 tel:13400010001打开拨号程序,http://www.g.cn则会打开浏览器等。

代码1:

Uri uri = Uri.parse("http://www.google.com");     //浏览器(网址必须带http)//Uri uri =Uri.parse("tel:1232333");              //拨号程序//Uri uri=Uri.parse("geo:39.899533,116.036476");  //打开地图定位Intent it  = new Intent(Intent.ACTION_VIEW,uri);  //Intent.ACTION_VIEW不带引号startActivity(it);

代码2:

//调用发送短信的程序Intent it = new Intent(Intent.ACTION_VIEW);    it.putExtra("sms_body", "信息内容...");    it.setType("vnd.android-dir/mms-sms");    startActivity(it); 

代码3:

//播放视频Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse("file:///sdcard/media.mp4"); intent.setDataAndType(uri, "video/*"); startActivity(intent); 


 

2 Intent.ACTION_SENDTO

String: android.intent.action.SENDTO

说明:发送短信息

//发送短信息Uri uri = Uri.parse("smsto:13200100001");    Intent it = new Intent(Intent.ACTION_SENDTO, uri);    it.putExtra("sms_body", "信息内容...");    startActivity(it); 

 

//发送彩信,设备会提示选择合适的程序发送Uri uri = Uri.parse("content://media/external/images/media/23"); //设备中的资源(图像或其他资源)  Intent intent = new Intent(Intent.ACTION_SEND);    intent.putExtra("sms_body", "内容");    intent.putExtra(Intent.EXTRA_STREAM, uri);    intent.setType("image/png");    startActivity(it); 

 

//EmailIntent intent=new Intent(Intent.ACTION_SEND);      String[] tos={"android1@163.com"};      String[] ccs={"you@yahoo.com"};      intent.putExtra(Intent.EXTRA_EMAIL, tos);      intent.putExtra(Intent.EXTRA_CC, ccs);      intent.putExtra(Intent.EXTRA_TEXT, "The email body text");      intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");      intent.setType("message/rfc822");      startActivity(Intent.createChooser(intent, "Choose Email Client"));  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Android开发笔记(三)—Activity和Intent机制
android 常用 INTENT - yinter - JavaEye技术网站
Intent跳转到系统应用中的拨号界面、联系人界面、短信界面及其他 | 老焦的小窝
Android中常用的几个intent
Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面 .相机.录影机.......
android之Uri的常用几个例子
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服