Intent只在Android中特有,我把它比作一种运载工具,就像飞机一样,会把一些人带到某个地方,而且如果需要的话,还可以找到机上有哪些人员(数据),这就需要另外一些设备来支持(如:Bundle),最后通过引擎(Context的 Activity)来启动。

以下是从网上摘来的:前人已有整理,就方便了我们这些后辈了。
1.显示网页:

Java代码 
  1. Uri uri = Uri.parse("http://www.google.com");
  2. Intent it  = new Intent(Intent.ACTION_VIEW,uri);
  3. startActivity(it);

2.显示地图:

Java代码 
  1. Uri uri = Uri.parse("geo:38.899533,-77.036476");
  2. Intent it = new Intent(Intent.Action_VIEW,uri);
  3. startActivity(it);

3.从google搜索内容

Java代码 
  1. Intent intent = new Intent();
  2. intent.setAction(Intent.ACTION_WEB_SEARCH);
  3. intent.putExtra(SearchManager.QUERY,"searchString")
  4. startActivity(intent);

4.路径规划

Java代码 
  1. Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat startLng&daddr=endLat endLng&hl=en");
  2. Intent it = new Intent(Intent.ACTION_VIEW,URI);
  3. startActivity(it);

5.拨打电话

Java代码 
  1. Uri uri = Uri.parse("tel:xxxxxx");
  2. Intent it = new Intent(Intent.ACTION_DIAL, uri);
  3. startActivity(it);
  4. [color=blue]//要使用这个必须在配置文件 中加入<uses-permission id="android .permission.CALL_PHONE" />[/color]

6.调用发短信的程序

Java代码 
  1. Intent it = new Intent(Intent.ACTION_VIEW);
  2. it.putExtra("sms_body", "The SMS text");
  3. it.setType("vnd.android-dir/mms-sms");
  4. startActivity(it);

7.发送短信

Java代码 
  1. Uri uri = Uri.parse("smsto:0800000123");
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  3. it.putExtra("sms_body", "The SMS text");
  4. startActivity(it);

8.发送彩信

Java代码 
  1. Uri uri = Uri.parse("content://media/external/images/media/23");
  2. Intent it = new Intent(Intent.ACTION_SEND);
  3. it.putExtra("sms_body", "some text");
  4. it.putExtra(Intent.EXTRA_STREAM, uri);
  5. it.setType("image/png");
  6. startActivity(it);

9.发送Email

Java代码 
  1. Uri uri = Uri.parse("mailto:xxx@abc.com");
  2. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  3. startActivity(it);
  4. Intent it = new Intent(Intent.ACTION_SEND);
  5. it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");
  6. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  7. it.setType("text/plain");
  8. startActivity(Intent.createChooser(it, "Choose Email Client"));
  9. Intent it=new Intent(Intent.ACTION_SEND);
  10. String[] tos={"me@abc.com"};
  11. String[] ccs={"you@abc.com"};
  12. it.putExtra(Intent.EXTRA_EMAIL, tos);
  13. it.putExtra(Intent.EXTRA_CC, ccs);
  14. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  15. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  16. it.setType("message/rfc822");
  17. startActivity(Intent.createChooser(it, "Choose Email Client"));
  18. Intent it = new Intent(Intent.ACTION_SEND);
  19. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  20. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
  21. sendIntent.setType("audio/mp3");
  22. startActivity(Intent.createChooser(it, "Choose Email Client"));

10.播放多媒体

Java代码 
  1. Intent it = new Intent(Intent.ACTION_VIEW);
  2. Uri uri = Uri.parse("file:///sdcard/song.mp3");
  3. it.setDataAndType(uri, "audio/mp3");
  4. startActivity(it);
  5. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
  6. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  7. startActivity(it);

11.install apk

Java代码 
  1. Uri installUri = Uri.fromParts("package", "xxx", null);
  2. returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);

12.uninstall apk

Java代码 
  1. Uri uri = Uri.fromParts("package", strPackageName, null);
  2. Intent it = new Intent(Intent.ACTION_DELETE, uri);
  3. startActivity(it);

13.发送附件

Java代码 
    1. Intent it = new Intent(Intent.ACTION_SEND);
    2. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
    3. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");
    4. sendIntent.setType("audio/mp3");
    5. startActivity(Intent.createChooser(it, "Choose Email Client"));

Android中Intent的用法总结的更多相关文章

  1. Android中Intent传值与Bundle传值的区别详解

    Android中Intent传值与Bundle传值的区别详解 举个例子我现在要从A界面跳转到B界面或者C界面   这样的话 我就需要写2个Intent如果你还要涉及的传值的话 你的Intent就要写两 ...

  2. android 中uri.parse()用法

    android 中uri.parse()用法 1,调web浏览器 Uri myBlogUri = Uri.parse("http://xxxxx.com"); returnIt = ...

  3. Android中Intent传递对象的两种方法(Serializable,Parcelable)

    今天要给大家讲一下Android中 Intent中如何传递对象,就我目前所知道的有两种方法,一种是Bundle.putSerializable(Key,Object);另一种是 Bundle.putP ...

  4. (转)Android中Parcelable接口用法

    1. Parcelable接口 Interface for classes whose instances can be written to and restored from a Parcel. ...

  5. [转]Android中Intent传递对象的两种方法(Serializable,Parcelable)

    http://blog.csdn.net/xyz_lmn/article/details/5908355 今天要给大家讲一下Android中Intent中如何传递对象,就我目前所知道的有两种方法,一种 ...

  6. Android中intent如何传递自定义数据类型

    转载自:http://www.cnblogs.com/GoAhead/archive/2012/07/16/2593868.html 大家好,好久不见,今天要给大家讲一下Android中Intent中 ...

  7. Android高手进阶教程(十七)之---Android中Intent传递对象的两种方法(Serializable,Parcelable)!

    [转][原文] 大家好,好久不见,今天要给大家讲一下Android中Intent中如何传递对象,就我目前所知道的有两种方法,一种是Bundle.putSerializable(Key,Object); ...

  8. 【转】Android中intent传递对象和Bundle的用法

    原文网址:http://blog.csdn.net/lixiang0522/article/details/8642202 android中的组件间传递的对象一般实现Parcelable接口,当然也可 ...

  9. Android中Intent组件详解

    Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件.Intent本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙 ...

随机推荐

  1. (转)Redis使用场景及使用经验

    Redis is an open source (BSD licensed), in-memory data structure store! 刚刚结束一个游戏类的活动项目,由于预估的参与人数较多,产 ...

  2. Restful API

    http://www.ruanyifeng.com/blog/2011/09/restful 参考资料:-------以网络为基础的应用软件的架构设计. Restful API的设计与实践 字数218 ...

  3. C# 委托&事件

    之前关于事件这块理解一直不是很好,正好有空复习,整理记录一下 委托:可以将与自身形式相同(返回参数相同:传入参数相同)的方法当成参数进行传递. using UnityEngine; using Sys ...

  4. html常用标签介绍

    常用标签介绍 文本 最常用的标签可能是<font>了,它用于改变字体,字号,文字颜色. 点击查看效果 <font size="6">6</font&g ...

  5. DBNEWNAME工具介绍

    下面修改数据库的SID和db_name [root@oracle ~]# su - ora11g db11@oracle /home/ora11g$ db11@oracle  /home/ora11g ...

  6. make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] 错误 1,make: *** [out/host/linux-x86/obj/lib/libESR_Portable.so] 错误 1

    错误3: g++: g++: selected multilib '32' not installed selected multilib '32' not installed make: *** [ ...

  7. Ubuntu服务器被黑经历(ElastichSearch漏洞)

    起因 最近我们的一台Ubuntu阿里云服务器一直提示有肉鸡行为,提示了好几天,开始并没有关注,然后连续几天后发现应该是个大问题啊.很可能服务被侵入了!!! 寻找线索 一开始我是完全懵逼的状态的,Lin ...

  8. PyQt5+Python3.5.2-32bit开发环境搭建

      1.基本环境. Window 8.1 64bit Python3.5.2-32bit.exe PyQt5 2.安装python. 去官网下载32位版本的python3.5.2(就是x86那个) 备 ...

  9. Javascript实现的数组降维——维度不同,怎么谈恋爱

    数组的元素可能是数组,这样一层层嵌套,可能得到一个嵌套很深的数组,数组降维要做的事就是把嵌套很深的数组展开,一般最后得到一个一维数组,其中的元素都是非数组元素,比如数组[1, [2, 3, [4, 5 ...

  10. CozyRSS开发记录13-添加订阅的对话框

    CozyRSS开发记录13-添加订阅的对话框 1.设计对话框 首先,还是先用MockPlus来画个原型图: 因为用了MaterialDesignToolkit,那么可以很方便的有一个蒙层的效果. 2. ...