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. 假如 UNION ALL 里面的子句 有 JOIN ,那个执行更快呢

    比如: select id, name from table1 where name = 'x' union all select id, name from table2 where name =  ...

  2. Linux Yum 安装JDK

    1.查看CentOS自带JDK是否已安装. 输入:yum list installed |grep java. 2.若有自带安装的JDK,如何卸载CentOS系统自带Java环境? 卸载JDK相关文件 ...

  3. windows系统 SVN出现 can't open file‘\XXX\txn-current-lock’ 拒绝访问 问题处理

    问题描述:  在新建的svn目录下,提交文件出现 如图错误提示.

  4. JavaScript 字符串处理详解

    一.创建字符串       创建一个字符串,将一组字符串用引号包起来,将其赋值给一个字符串变量. var JsStr="Hello,JavaScript String!"; 二.字 ...

  5. Oracle REGEXP_SUBSTR()

    REGEXP_SUBSTR函数格式如下: function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)       _ ...

  6. [转]序列化悍将Protobuf-Net,入门动手实录

    最近在研究web api 2,看了一篇文章,讲解如何提升性能的, 在序列化速度的跑分中,Protobuf一骑绝尘,序列化速度快,性能强,体积小,所以打算了解下这个利器 1:安装篇 谷歌官方没有提供.n ...

  7. Etw EventSourceProvider_EventsProducer.cs OopConsoleTraceEventListenerMonitor_TraceControllerEventsConsumer.cs

    // EventSourceProvider_EventsProducer.cs /* /r:"D:\Microshaoft.Nuget.Packages\Microsoft.Diagnos ...

  8. Spring MVC重定向和转发及异常处理

    SpringMVC核心技术---转发和重定向 当处理器对请求处理完毕后,向其他资源进行跳转时,有两种跳转方式:请求转发与重定向.而根据要跳转的资源类型,又可分为两类:跳转到页面与跳转到其他处理器.对于 ...

  9. 常见css垂直自适应布局(css解决方法)

    css3的盒模型, css3中添加弹性盒模型,最新弹性盒模型是flex,之前为box <!DOCTYPE html> <html > <head> <titl ...

  10. POJ 1743 Musical Theme ——后缀数组

    [题目分析] 其实找最长的不重叠字串是很容易的,后缀数组+二分可以在nlogn的时间内解决. 但是转调是个棘手的事情. 其实只需要o(* ̄▽ ̄*)ブ差分就可以了. 背板题. [代码] #include ...