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. centos7.0 下安装git(ssh方式)

    最近刚弄了个阿里云,在上面弄个git服务器,这里只弄了ssh方式访问,http方式访问的可以看我另外一个随笔http://www.cnblogs.com/hz-cww/p/6077970.html. ...

  2. 用极简方式实现新浪新版本特性展示效果--view的图片轮播

    在发布版本的时候,大多数软件会在第一次使用新版本时候弹出视图用几张图片给用户做一个新版本特性介绍,最简单如下图新浪的版本特性介绍 由于图片是全屏展示且是左右滑动,大多数情况开发者会选择使用scroll ...

  3. 使用Nito.AsyncEx实现异步锁(转)

    转载地址:http://www.cnblogs.com/1zhk/p/5269279.html Lock是常用的同步锁,但是我们无法在Lock的内部实现异步调用,比如我们无法使用await. 以下面的 ...

  4. myeclipse一直卡在loading workbench解决方法

    删除工作空间下.metadata中的org.eclipse.ui.workbench org.eclipse.ui.workbench.texteditor

  5. byte[] 转十进制

    short s = 0; //一个16位整形变量,初值为 0000 0000 0000 0000 byte b1 = 1; //一个byte的变量,作为转换后的高8位,假设初值为 0000 0001 ...

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

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

  7. #英文#品读中国城市个性——秦汉雄风&和祖先在一起

    妨碍 interfere with 仇恨 hatred ​坍塌 collapse 专制君主 autocratic dictator 排除异己 suppress opposition 被逼到绝望边缘 b ...

  8. ZoomEye 钟馗之眼 搜索工具 基于API

    #!/usr/bin/env python # -*- coding: utf-8 -*- # Author: f0rsaken import getopt import requests impor ...

  9. time的用法

    线程计时器(System.Threading.Timer) System.Windows.Threading.DispatcherTimer tRecorderTimer; if (tRecorder ...

  10. SqlServer查询表中各列名称、表中列数

    查询表名为tb_menu的所有列名 select name from syscolumns where id=object_id('tb_menu')     查询表名为tb_menu的所有列名个数 ...