Intent 隐示意图
1.从google搜索内容
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"searchString")
startActivity(intent);
2.浏览网页
Uri uri = Uri.parse("http://www.google.com");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
3.显示地图
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
4.路径规划
Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&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);
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);
String body="this is sms demo";
Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null));
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);
startActivity(mmsintent);
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);
StringBuilder sb = new StringBuilder();
sb.append("file://");
sb.append(fd.getAbsoluteFile());
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null));
// Below extra datas are all optional.
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());
intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);
startActivity(intent);
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.uninstall apk
Uri uri = Uri.fromParts("package", strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
12.install apk
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
13. 打开照相机
<1>Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
this.sendBroadcast(i);
<2>long dateTaken = System.currentTimeMillis();
String name = createName(dateTaken) + ".jpg";
fileName = folder + name;
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, fileName);
values.put("_data", fileName);
values.put(Images.Media.PICASA_ID, fileName);
values.put(Images.Media.DISPLAY_NAME, fileName);
values.put(Images.Media.DESCRIPTION, fileName);
values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName);
Uri photoUri = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(inttPhoto, 10);
14.从gallery选取图片
Intent i = new Intent();
i.setType("image/*");
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(i, 11);
15. 打开录音机
Intent mi = new Intent(Media.RECORD_SOUND_ACTION);
startActivity(mi);
16.显示应用详细列表
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
刚才找app id未果,结果发现用package name也可以
Uri uri = Uri.parse("market://details?id=<packagename>");
这个简单多了
17.寻找应用
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
18.打开联系人列表
<1>
Intent i = new Intent();
i.setAction(Intent.ACTION_GET_CONTENT);
i.setType("vnd.android.cursor.item/phone");
startActivityForResult(i, REQUEST_TEXT);
<2>
Uri uri = Uri.parse("content://contacts/people");
Intent it = new Intent(Intent.ACTION_PICK, uri);
startActivityForResult(it, REQUEST_TEXT);
19.打开另一程序
Intent i = new Intent();
ComponentName cn = new ComponentName("com.yellowbook.android2",
"com.yellowbook.android2.AndroidSearch");
i.setComponent(cn);
i.setAction("android.intent.action.MAIN");
startActivityForResult(i, RESULT_OK);
//调用浏览器Uri uri = Uri.parse("");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
//显示某个坐标在地图上Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
//显示路径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);
//拨打电话Uri uri = Uri.parse("tel:10086");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);Uri uri = Uri.parse("tel.10086");
Intent it =new Intent(Intent.ACTION_CALL,uri);
需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml
//发送短信或彩信Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "The SMS text");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
//发送短信Uri uri = Uri.parse("smsto:10086");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "cwj");
startActivity(it);
//发送彩信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);
//发送邮件
Uri uri = Uri.parse("mailto:android123@163.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, android123@163.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_VIEW);
Uri uri = Uri.parse("[url=]file:///sdcard/cwj.mp3[/url]");
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);
//卸载APKUri uri = Uri.fromParts("package", strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
//卸载apk 2
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
//安装APK
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
//播放音乐Uri playUri = Uri.parse("[url=]/sdcard/download/sth.mp3[/url]");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);
//发送附近Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, "[url=]file:///sdcard/cwj.mp3[/url]");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it, "Choose Email Client"));
//market上某个应用信,pkg_name就是应用的packageNameUri uri = Uri.parse("market://search?q=pname:pkg_name");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//market上某个应用信息,app_id可以通过www网站看下Uri uri = Uri.parse("market://details?id=app_id");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//调用搜索Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123")
startActivity(intent);
对于android的显示隐示意图可以参考这篇博客,写的很详细:
隐示intent 不明确指定要启动那个intent,由系统去筛选合适的activity
Android理解:显式和隐式Intent http://blog.csdn.net/xiao__gui/article/details/11392987
Intent 隐示意图相关推荐
- android之隐示意图跳转启动另一个activity
主面板布局:layout/activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/r ...
- intent隐式和显式_Neo4j:使隐式关系成为显式和双向关系
intent隐式和显式 我最近阅读了Michal Bachman关于 Neo4j中双向关系的文章 ,他建议对于某些关系类型,我们对关系的方向不那么感兴趣,因此可以在查询时忽略它. 他使用以下示例显示N ...
- android intent隐式启动一个隐藏图标的APP
intent隐式启动被隐藏图标的activity的方法 今天开发安卓的时候遇到了一个问题,被隐藏掉图标的apk程序,用另一个apk隐式启动的时候,报错. 网上百度了一圈,都说加上category.DE ...
- Android Intent隐式启动通过scheme打开应用
1. 什么是隐式Intent? Intent是Android中比较重要的组件,常用来启动一个新的Activity或者Service.广播某个事件,以及在Android组件之间传递数据.通过Intent ...
- Android Studio Intent使用(显式、隐式)
https://blog.csdn.net/u012005313/article/details/47006689 使用Intent能够使程序在不同活动中跳转,意及能够使用不同界面.Intent用法分 ...
- 显式Intent 和隐式 Intent 的区别
显式 Intent : 在知道目标组件名称的前提下,去调用Intent.setComponent().Intent.setClassName()或Intent.setClass()方法或者在new I ...
- Android Intent常用方法详细介绍,显示Intent,隐式Intent,调用浏览器,拨号,发短信,传递数据
Intent介绍 Intent是Android程序中各个组件之间进行交互的一种重要方式,它不仅可以指明当前组件想要执行的动作,还可以在不同组件之间传递数据.Intent一般用于启动活动,启动服务以及发 ...
- Android初学之二:显示Intent和隐示Intent
一.显式Intent 1.示范如何实现活动跳转 在按钮的点击事件里: a.调用构造函数Intent(Context packageContext,Class<?>cls),第一参数是上下文 ...
- Android(Intent意图初解,显示意图,隐式意图,意图过滤器)
Android Intent 简介:Intent被称为意图,是安卓程序中的一种比较重要的组件间交户的方式,可以用于组件间的跳转,传递数据等.通常用作启动Activity,Service以及发送广播等. ...
最新文章
- 离职后竟半夜偷溜回办公室写代码?一个为自由软件而战斗的程序员
- 【JavaScript】【PPT】继承的本质
- A query was run and no Result Maps were found for the Mapped Statement....
- ionic build Android错误记录 error in opening zip file
- 操作系统学习笔记-01-操作系统的概念(定义),功能和目标
- 【计算机网络复习 物理层】2.3 物理层设备
- 关于浙大考研878历年试卷的说明
- mysql常用加密方法_MYSQL 加密的 3 类方法
- Acoustica 7 for mac最新版 (数字音频编辑器)
- 我是如何获取新知识的?
- C# 中,利用 Conditional 定义条件方法
- 数字通信原理笔记(一)---概述
- 迈捷php邮箱系统源码,10分钟临时邮箱源码-php bccto.me的php版本源码 windows主机即可 - 下载 - 搜珍网...
- 大数据与数据挖掘的相对绝对关系
- 加州大学欧文分校 计算机专业,加州大学欧文分校信息与计算机科学
- ie9兼容css正常吗,针对IE9的CSS兼容
- dpkg: 处理软件包 xxxxxxxx (–configure)时出错:
- 安装oracle需要多少内存,安装Oracle11g的内存要求至少1G的物理内存输入如下命令查看物理...
- 【js特效】www.zhen.com图片频道页特效
- oracle 11g的安装
热门文章
- linux安装系统ftp服务器配置,linux系统搭建ftp服务器的配置方 - 电子发烧友网
- SQL Server上的审计表和数据版本控制
- Linux sudo 被曝提权漏洞,任意用户均能以 root 身份运行命令
- 大工18春计算机文化基础在线测试1,大工18春《计算机文化基础》在线测试1(满分答案)...
- matlab中取文件名函数,matlab从文件夹名中获取该文件夹下所图像文件名
- linux 内网文件传输工具_不管你是新手PHP程序员还是大佬都要知道的PHP十大必备工具...
- numpy 矩阵求逆_numpy 矩阵运算
- php 使用支付宝SDK报错解决
- label mpchart 饼图_Android MPChart—饼图-Go语言中文社区
- 前端埋点的缺点_【埋点学习埋点质量】埋点的框架设计及其准确性