几种Intent 的用法
显示网页:
Uri uri = Uri.parse(”http://www.google.com”);
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
显示地图:
Uri uri = Uri.parse(”geo:38.899533,-77.036476″);
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
路径规划:
Uri uri = Uri.parse(”http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);
Intent it = new Intent(Intent.ACTION_VIEW,URI);
startActivity(it);
拨打电话:
调用拨号程序
Uri uri = Uri.parse(”tel:xxxxxx”);
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
Uri uri = Uri.parse(”tel.xxxxxx”);
Intent it =new Intent(Intent.ACTION_CALL,uri);
要使用这个必须在配置文件 中加入
发送SMS/MMS
调用发送短信 的程序
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra(”sms_body”, “The SMS text”);
it.setType(”vnd.android-dir/mms-sms”);
startActivity(it);
发送短信
Uri uri = Uri.parse(”smsto:0800000123″);
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra(”sms_body”, “The SMS text”);
startActivity(it);
发送彩信
Uri uri = Uri.parse(”content://media/external/images/media/23″);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(”sms_body”, “some text”);
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType(”image/png”);
startActivity(it);
发送Email
Uri uri = Uri.parse(”mailto:xxx@abc.com”);
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, “me@abc.com”);
it.putExtra(Intent.EXTRA_TEXT, “The email body text”);
it.setType(”text/plain”);
startActivity(Intent.createChooser(it, “Choose Email Client”));
Intent it=new Intent(Intent.ACTION_SEND);
String[] tos={”me@abc.com”};
String[] ccs={”you@abc.com”};
it.putExtra(Intent.EXTRA_EMAIL, tos);
it.putExtra(Intent.EXTRA_CC, ccs);
it.putExtra(Intent.EXTRA_TEXT, “The email body text”);
it.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
it.setType(”message/rfc822″);
startActivity(Intent.createChooser(it, “Choose Email Client”));
添加附件
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
it.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);
sendIntent.setType(”audio/mp3″);
startActivity(Intent.createChooser(it, “Choose Email Client”));
播放 多媒体
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(”file:///sdcard/song.mp3″);
it.setDataAndType(uri, “audio/mp3″);
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, “1″);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
Uninstall 程序
Uri uri = Uri.fromParts(”package”, strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
uninstall apk
Uri uninstallUri = Uri.fromParts(”package”, “xxx”, null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
install apk
Uri installUri = Uri.fromParts(”package”, “xxx”, null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
play audio
Uri playUri = Uri.parse(”file:///sdcard/download/everything.mp3″);
returnIt = new Intent(Intent.ACTION_VIEW, playUri);
//发送附件
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
it.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/eoe.mp3″);
sendIntent.setType(”audio/mp3″);
startActivity(Intent.createChooser(it, “Choose Email Client”));
//搜索应用
Uri uri = Uri.parse(”market://search?q=pname:pkg_name”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where pkg_name is the full package path for an application
//显示指定应用的详细页面(这个好像不支持了,找不到app_id)
Uri uri = Uri.parse(”market://details?id=app_id”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where app_id is the application ID, find the ID
//by clicking on your application on Market home
//page, and notice the ID from the address bar
几种Intent 的用法相关推荐
- Intent 的用法
1.用Context指定 Intent i=new Intent(context,Receivered.class); context.startActivity(i); 2.通过配置指定 < ...
- Java的几种常见接口用法
2019独角兽企业重金招聘Python工程师标准>>> Java的几种常见接口用法 今天在看阎宏的< Java与模式>,里面对 java的 几种 接口的常用方法的总结: ...
- 数据绑定以及Container.DataItem几种方式与用法分析 收藏
数据绑定以及Container.DataItem几种方式与用法分析 收藏 灵活的运用数据绑定操作 绑定到简单属性:<%#UserName%> 绑定到集合:& ...
- FreeMarker四种变量的用法
原文:http://www.656463.com/article/286 摘要: freemarker的变量可以分为四种,分别是数据模型的变量[root中的变量],模板中的变量使用[<#assi ...
- 避免常见的6种HTML5错误用法,如何避免常见的6种HTML5错误用法
一.不要使用section作为div的替代品 人们在标签使用中最常见到的错误之一就是随意将HTML5的等价于 --具体地说,就是直接用作替代品(用于样式).在XHTML或者HTML4中,我们常看到这样 ...
- 计算机曝光模式有哪些,摄影:单反相机中P、A、S、M四种曝光模式的用法详解 -电脑资料...
这篇教程是向脚本之家的朋友介绍单反相机中P.A.S.M四种曝光模式的用法,对于摄影爱好者非常值得学习,推荐到脚本之家,喜欢的朋友一起来看看吧 很多朋友在初接触单反相机时对相机的P.A.S.M四种曝光模 ...
- [转]jQuery的each方法的几种常用的用法
下面提一下jQuery的each方法的几种常用的用法 复制代码 代码如下: var arr = [ "one", "two", "three&quo ...
- 几种for循环用法详解。
本文非常适合初学Java的程序员,主要是来了解一下Java中的几种for循环用法,分析得十分详细,一起来看看. J2SE 1.5提供了另一种形式的for循环.借助这种形式的for循环,可以用更简单地方 ...
- Java 枚举(enum) 7种常见的用法
在JDK1.5引入了新的类型--枚举.在 Java 中它虽然算个"小"功能,却给我的开发带来了"大"方便. 用法一:常量 在JDK1.5 之前,我们定义常量都是 ...
最新文章
- 电商项目商品搜索模块 - ESik分词器安装
- PADS2007中的层类型(plane type) 简介
- java中的io复用_从 Java 中的零拷贝到五种IO模型
- enum中使用中文 unity_自定义Unity材质Inspector之枚举类型(Enum)
- 关于Java交换两个对象的问题
- GTK+ tutorial
- python绘制拟合回归散点图_Python之简单线性回归
- 深度学习要多深_才能读懂人话?
- Ubuntu无法安装Xmind rpm包
- java初中级程序员面试宝典-蚂蚁课堂
- 鹏城实验室支持建设的OpenI启智社区荣登2021“科创中国”开源创新榜
- 计算机怎样更新目录,怎么在word中设置自动更新目录功能
- Apache Tomcat AJP 文件包含漏洞复现(CVE-2020-10487)
- 网络数据爬取实例教程
- 工作流任务调度系统:Apache DolphinScheduler
- 在pcb放置坐标标注_PCB设计定位基准符号和尺寸
- 每日一道SQL题(第N高的薪水)
- c语言中“|”和“||”区别
- 如何在博客插入UML图
- avc水平什么意思_AVC是什么?
热门文章
- 计算机网络的DIX,《计算机网络》期末考试试卷(B卷)
- getlock mysql_mysql中的get_lock锁机制解析
- android动态添加控件在指定位置,Android 如何动态添加 View 并显示在指定位置。
- HeidiSQL- csv 表格导入数据到 DB表
- 拉普拉斯算子_图机器学习图拉普拉斯算子的离散正则性,141页ppt,Discrete regularity graph Laplacians...
- input位置_3分钟短文 | PHP 数组任意位置插入新元素,你是怎么处理的?
- 判断double_深入解析单例模式之懒汉模式---Double-Check及volatile关键字
- invoke 魔术_PHP常用魔术方法(__invoke魔术方法)
- chrome vue.js插件文档_前端开发者必备的40个VSCode插件!
- Linux7没有网卡,centos7安装后缺少网卡如何解决?