`

Intent常用Uri

 
阅读更多
 一、打开一个网页,类别是Intent.ACTION_VIEW
  Uri uri = Uri.parse(“http://www.chinasofti.com/”);
  Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 二、打开地图并定位到一个点
  Uri uri = Uri.parse(“geo:52.76,-79.0342″);
  Intent intent = new Intent(Intent.ACTION_VIEW, uri);
 三、打开拨号界面 ,类型是Intent.ACTION_DIAL
  Uri uri = Uri.parse(“tel:10086″);
  Intent intent = new Intent(Intent.ACTION_DIAL, uri);
 四、直接拨打电话,与三不同的是,这个直接拨打电话,而不是打开拨号界面
  Uri uri = Uri.parse(“tel:10086″);
  Intent intent = new Intent(Intent.ACTION_CALL, uri);
 五、卸载一个应用,Intent的类别是Intent.ACTION_DELETE
  Uri uri = Uri.fromParts(“package”, “xxx”, null);
  Intent intent = new Intent(Intent.ACTION_DELETE, uri);
 六、安装应用程序,Intent的类别是Intent.ACTION_PACKAGE_ADDED
  Uri uri = Uri.fromParts(“package”, “xxx”, null);
  Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);
 七、播放音频文件
  Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″);
  Intent intent = new Intent(Intent.ACTION_VIEW, uri);
  intent.setType(“audio/mp3″);
 八、打开发邮件界面
  Uri uri= Uri.parse(“mailto:test@163.com”);
  Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
 九、发邮件,与八不同这里是将邮件发送出去,
  Intent intent = new Intent(Intent.ACTION_SEND);
  String[] tos = { “ mailto:test@163.com ” };
  String[] ccs = { “ test1@163.com ” };
  intent.putExtra(Intent.EXTRA_EMAIL, tos);
  intent.putExtra(Intent.EXTRA_CC, ccs);
  intent.putExtra(Intent.EXTRA_TEXT, “I come from      http://www.chinasofti.com”);
intent.putExtra(Intent.EXTRA_SUBJECT, “http://www.chinasofti.com”);
intent.setType(“message/rfc882″);
  Intent.createChooser(intent, “Choose Email Client”);
  //发送带附件的邮件
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
  intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);
  intent.setType(“audio/mp3″);
  startActivity(Intent.createChooser(intent, “Choose Email Client”));
十、发短信
  Uri uri= Uri.parse(“tel:10086″);
  Intent intent = new Intent(Intent.ACTION_VIEW, uri);
  intent.putExtra(“sms_body”, “I come from http://www.chinasofti.com”);
  intent.setType(“vnd.android-dir/mms-sms”);
十一、直接发邮件
  Uri uri= Uri.parse(“smsto://100861″);
  Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
  intent.putExtra(“sms_body”, “3g android http://www.chinasofti.com”);
十二、发彩信
  Uri uri= Uri.parse(“content://media/external/images/media/23″);
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.putExtra(“sms_body”, “3g android http://www.chinasofti.com”);
  intent.putExtra(Intent.EXTRA_STREAM, uri);
  intent.setType(“image/png”);
十三、# Market 相关
  1 //寻找某个应用
  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
  2 //显示某个应用的相关信息
  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
十四、路径规划
  Uri uri = Uri.parse(“http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);
  Intent it = new Intent(Intent.ACTION_VIEW, uri);
  startActivity(it);

分享到:
评论

相关推荐

    Android 常用的Intent的URI及示例

    Android 常用的Intent的URI及示例 很全很强大

    Android Intent调用 Uri的方法总结

    主要介绍了Android Intent调用 Uri的方法总结的相关资料,这里整理了Android Intent 调用Uri的常用方法,需要的朋友可以参考下

    android常用意图

    android意图 以下是常用到的Intent的URI及其示例,包含了大部分应用中用到的共用Intent。

    Android开发中Intent.Action各种常见的作用汇总

    本文介绍Android中Intent的各种常见作用。 1 Intent.ACTION_MAIN ...比较常用。 Input:nothing Output:nothing <intent> <action android:name=android.intent.action.MAIN> <category androi

    36个Android开发常用经典代码大全

    本文汇集36个Android开发常用经典代码片段,包括拨打电话、发送短信、... context.startActivity( new Intent(Intent.ACTION_CALL, Uri.parse( tel: + phoneNumber))); } //跳转至拨号界面 public static void call

    android开发——简易计算器的设计报告.doc

    传过去:函数原型为: public Intent setData(ContentURI data) 然后,参数带到新的Activity后,同样用Activity.getIntent()函数可得到当前过来的 Intent对象,然后用getData()就取到参数了。 传回来:函数原型为: ...

    adb1.0.26包含fastboot.exe

    在多个设备/模拟器连接的情况下较常用的是 -s <serialNumber> 参数,serialNumber 可以通过 adb devices 命令获取。如: $ adb devices List of devices attached cf264b8f device emulator-5554 device 10.129....

    Android实例代码

    15.2、Android的常用传感器:方向传感器Orientation; 磁场传感器Magnetic Field; 温度传感器Temperature; 光传感器Light; 压力传感器Pressure; 第16章、GPS应用开发 16.1、支持GPS的核心API: 16.2、获取...

    疯狂Android讲义(第2版)源代码 第6章~第9章

    15.2、Android的常用传感器:方向传感器Orientation; 磁场传感器Magnetic Field; 温度传感器Temperature; 光传感器Light; 压力传感器Pressure; 第16章、GPS应用开发 16.1、支持GPS的核心API: 16.2、获取...

    黑马程序员 安卓学院 万元哥项目经理 分享220个代码实例

    |--Intent常用功能 |--IO将输入流转成字节 |--Json读js资源文件 |--layout布局样式之style配置 |--listview 页面 图片加文字 |--ListView之CursorAdapter异步查询框架之短信 |--ListView之动态添加子view |--...

    新版Android开发教程.rar

    ----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...

    Android开发案例驱动教程 配套代码

    4.4 Activity中的常用事件 53 4.4.1 触摸事件 53 4.4.2 键盘事件 55 4.5 菜单 57 4.5.1 文本菜单 57 4.5.2 图片文本菜单 59 本章小结 60 第5章 UI基础控件 61 5.1 按钮 61 5.1.1 Button 62 5.1.2 ...

    疯狂Android讲义源码

     9.1.2 Uri简介 353  9.1.3 使用ContentResolver操作  数据 354  9.2 操作系统的ContentProvider 355  9.2.1 使用ContentProvider管理  联系人 355  9.2.2 使用ContentProvider管理  多媒体内容 360  9.3 ...

    疯狂Android讲义.part2

    9.1.2 Uri简介 353 9.1.3 使用ContentResolver操作 数据 354 9.2 操作系统的ContentProvider 355 9.2.1 使用ContentProvider管理 联系人 355 9.2.2 使用ContentProvider管理 多媒体内容 360 9.3 实现ContentProvider...

    疯狂Android讲义.part1

    9.1.2 Uri简介 353 9.1.3 使用ContentResolver操作 数据 354 9.2 操作系统的ContentProvider 355 9.2.1 使用ContentProvider管理 联系人 355 9.2.2 使用ContentProvider管理 多媒体内容 360 9.3 实现ContentProvider...

    android nfc常用标签读取总结

    有几天没有更新博客了,不过本篇却准备了许久,希望能带给每一位开发者最简单高效的学习方式。废话到此为止,下面开始正文。 NFC(Near Field Communication,近场通信)是一种数据传输技术。...

    Activity生命周期与启动模式图文解说

    Activity作为Android开发中最常用的一个组件,是Android开发人员必须熟悉且掌握的重要内容。同时Activity也是在面试中经常被问到的一个方向。因此,掌握Activity的重要性也不言而喻。希望能够对Activity有一个较为...

Global site tag (gtag.js) - Google Analytics