Android中Intent的用法总结
Intent只在Android中特有,我把它比作一种运载工具,就像飞机一样,会把一些人带到某个地方,而且如果需要的话,还可以找到机上有哪些人员(数据),这就需要另外一些设备来支持(如:Bundle),最后通过引擎(Context的 Activity)来启动。
以下是从网上摘来的:前人已有整理,就方便了我们这些后辈了。
1.显示网页:
- Uri uri = Uri.parse("http://www.google.com");
- Intent it = new Intent(Intent.ACTION_VIEW,uri);
- startActivity(it);
2.显示地图:

- Uri uri = Uri.parse("geo:38.899533,-77.036476");
- Intent it = new Intent(Intent.Action_VIEW,uri);
- startActivity(it);
3.从google搜索内容
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_WEB_SEARCH);
- intent.putExtra(SearchManager.QUERY,"searchString")
- startActivity(intent);
4.路径规划

- Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat startLng&daddr=endLat endLng&hl=en");
- Intent it = new Intent(Intent.ACTION_VIEW,URI);
- startActivity(it);
5.拨打电话
- Uri uri = Uri.parse("tel:xxxxxx");
- Intent it = new Intent(Intent.ACTION_DIAL, uri);
- startActivity(it);
- [color=blue]//要使用这个必须在配置文件 中加入<uses-permission id="android .permission.CALL_PHONE" />[/color]
6.调用发短信的程序
- Intent it = new Intent(Intent.ACTION_VIEW);
- it.putExtra("sms_body", "The SMS text");
- it.setType("vnd.android-dir/mms-sms");
- startActivity(it);
7.发送短信
- Uri uri = Uri.parse("smsto:0800000123");
- Intent it = new Intent(Intent.ACTION_SENDTO, uri);
- it.putExtra("sms_body", "The SMS text");
- startActivity(it);
8.发送彩信
- 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);
9.发送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"));
10.播放多媒体
- 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);
11.install apk
- Uri installUri = Uri.fromParts("package", "xxx", null);
- returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
12.uninstall apk
- Uri uri = Uri.fromParts("package", strPackageName, null);
- Intent it = new Intent(Intent.ACTION_DELETE, uri);
- startActivity(it);
13.发送附件
- 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"));
Android中Intent的用法总结的更多相关文章
- Android中Intent传值与Bundle传值的区别详解
Android中Intent传值与Bundle传值的区别详解 举个例子我现在要从A界面跳转到B界面或者C界面 这样的话 我就需要写2个Intent如果你还要涉及的传值的话 你的Intent就要写两 ...
- android 中uri.parse()用法
android 中uri.parse()用法 1,调web浏览器 Uri myBlogUri = Uri.parse("http://xxxxx.com"); returnIt = ...
- Android中Intent传递对象的两种方法(Serializable,Parcelable)
今天要给大家讲一下Android中 Intent中如何传递对象,就我目前所知道的有两种方法,一种是Bundle.putSerializable(Key,Object);另一种是 Bundle.putP ...
- (转)Android中Parcelable接口用法
1. Parcelable接口 Interface for classes whose instances can be written to and restored from a Parcel. ...
- [转]Android中Intent传递对象的两种方法(Serializable,Parcelable)
http://blog.csdn.net/xyz_lmn/article/details/5908355 今天要给大家讲一下Android中Intent中如何传递对象,就我目前所知道的有两种方法,一种 ...
- Android中intent如何传递自定义数据类型
转载自:http://www.cnblogs.com/GoAhead/archive/2012/07/16/2593868.html 大家好,好久不见,今天要给大家讲一下Android中Intent中 ...
- Android高手进阶教程(十七)之---Android中Intent传递对象的两种方法(Serializable,Parcelable)!
[转][原文] 大家好,好久不见,今天要给大家讲一下Android中Intent中如何传递对象,就我目前所知道的有两种方法,一种是Bundle.putSerializable(Key,Object); ...
- 【转】Android中intent传递对象和Bundle的用法
原文网址:http://blog.csdn.net/lixiang0522/article/details/8642202 android中的组件间传递的对象一般实现Parcelable接口,当然也可 ...
- Android中Intent组件详解
Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件.Intent本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙 ...
随机推荐
- 假如 UNION ALL 里面的子句 有 JOIN ,那个执行更快呢
比如: select id, name from table1 where name = 'x' union all select id, name from table2 where name = ...
- Linux Yum 安装JDK
1.查看CentOS自带JDK是否已安装. 输入:yum list installed |grep java. 2.若有自带安装的JDK,如何卸载CentOS系统自带Java环境? 卸载JDK相关文件 ...
- windows系统 SVN出现 can't open file‘\XXX\txn-current-lock’ 拒绝访问 问题处理
问题描述: 在新建的svn目录下,提交文件出现 如图错误提示.
- JavaScript 字符串处理详解
一.创建字符串 创建一个字符串,将一组字符串用引号包起来,将其赋值给一个字符串变量. var JsStr="Hello,JavaScript String!"; 二.字 ...
- Oracle REGEXP_SUBSTR()
REGEXP_SUBSTR函数格式如下: function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier) _ ...
- [转]序列化悍将Protobuf-Net,入门动手实录
最近在研究web api 2,看了一篇文章,讲解如何提升性能的, 在序列化速度的跑分中,Protobuf一骑绝尘,序列化速度快,性能强,体积小,所以打算了解下这个利器 1:安装篇 谷歌官方没有提供.n ...
- Etw EventSourceProvider_EventsProducer.cs OopConsoleTraceEventListenerMonitor_TraceControllerEventsConsumer.cs
// EventSourceProvider_EventsProducer.cs /* /r:"D:\Microshaoft.Nuget.Packages\Microsoft.Diagnos ...
- Spring MVC重定向和转发及异常处理
SpringMVC核心技术---转发和重定向 当处理器对请求处理完毕后,向其他资源进行跳转时,有两种跳转方式:请求转发与重定向.而根据要跳转的资源类型,又可分为两类:跳转到页面与跳转到其他处理器.对于 ...
- 常见css垂直自适应布局(css解决方法)
css3的盒模型, css3中添加弹性盒模型,最新弹性盒模型是flex,之前为box <!DOCTYPE html> <html > <head> <titl ...
- POJ 1743 Musical Theme ——后缀数组
[题目分析] 其实找最长的不重叠字串是很容易的,后缀数组+二分可以在nlogn的时间内解决. 但是转调是个棘手的事情. 其实只需要o(* ̄▽ ̄*)ブ差分就可以了. 背板题. [代码] #include ...