intent调用代码总结
进入联系人界面
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(People.CONTENT_URI);
startActivity(intent);
查看某个联系人,当然这里是ACTION_VIEW,如果为选择并返回action改为ACTION_PICK,当然处理intent时返回需要用到startActivityforResult
Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, ID);//最后的ID参数为联系人Provider中的数据库BaseID,即哪一行
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(personUri);
startActivity(intent);
选择一个图片
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
startActivityForResult(intent, );
调用Android设备的照相机,并设置拍照后存放位置
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment
.getExternalStorageDirectory().getAbsolutePath()+"/cwj", android123 + ".jpg"))); //存放位置为sdcard卡上cwj文件夹,文件名为android123.jpg格式
startActivityForResult(intent, );
搜索指定package name在market上,比如搜索com.android123.cwj的写法如下
Uri uri = Uri.parse("market://search?q=pname:com.android123.cwj");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
显示Web网页:
. Uri uri = Uri.parse("http://www.android123.com.cn");
. Intent it = new Intent(Intent.ACTION_VIEW,uri);
. startActivity(it);
显示Google地图:
. Uri uri = Uri.parse("geo:38.899533,-77.036476");
. Intent it = new Intent(Intent.Action_VIEW,uri);
. startActivity(it);
Maps路径规划:
. 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:xxxxxx");
. Intent it = new Intent(Intent.ACTION_DIAL, uri);
. startActivity(it);
. Uri uri = Uri.parse("tel.xxxxxx");
. Intent it =new Intent(Intent.ACTION_CALL,uri);
注意需要权限 <uses-permission id="android.permission.CALL_PHONE" />
发送SMS/MMS
. Intent it = new Intent(Intent.ACTION_VIEW);
. it.putExtra("sms_body", "android开发网欢迎您");
. 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", ""); //正文为10086
. startActivity(it);
发送彩信
. Uri uri = Uri.parse("content://media/external/images/media/10"); //该Uri根据实际情况修改,external代表外部存储即sdcard
. Intent it = new Intent(Intent.ACTION_SEND);
. it.putExtra("sms_body", "android123.com.cn");
. it.putExtra(Intent.EXTRA_STREAM, uri);
. it.setType("image/png");
. startActivity(it);
发送Email
. 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, "android开发网测试");
. it.setType("text/plain");
. startActivity(Intent.createChooser(it, "选择一个Email客户端"));
. Intent it=new Intent(Intent.ACTION_SEND);
. String[] tos={"android123@163.com"}; //发送到
. String[] ccs={"ophone123@163.com"}; //抄送
. it.putExtra(Intent.EXTRA_EMAIL, tos);
. it.putExtra(Intent.EXTRA_CC, ccs);
. it.putExtra(Intent.EXTRA_TEXT, "正文");
. it.putExtra(Intent.EXTRA_SUBJECT, "标题");
. it.setType("message/rfc822"); //编码类型
. startActivity(Intent.createChooser(it, "选择一个Email客户端"));
Email添加附件
. Intent it = new Intent(Intent.ACTION_SEND);
. it.putExtra(Intent.EXTRA_SUBJECT, "正文");
. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/nobody.mp3"); //附件为sd卡上的nobody MP3文件
. sendIntent.setType("audio/mp3");
. startActivity(Intent.createChooser(it, "选择一个Email客户端"));
播放多媒体
.
. Intent it = new Intent(Intent.ACTION_VIEW);
. Uri uri = Uri.parse("file:///sdcard/nobody.mp3");
. it.setDataAndType(uri, "audio/mp3");
. startActivity(it); . Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, ""); //从系统内部的MediaProvider索引中调用播放
. Intent it = new Intent(Intent.ACTION_VIEW, uri);
. startActivity(it);
Uninstall卸载程序
. Uri uri = Uri.fromParts("package", packageName, null); //packageName为包名,比如com.android123.apkInstaller
. Intent it = new Intent(Intent.ACTION_DELETE, uri);
. startActivity(it);
Installer安装APK
这里安装APK文件的方法参考 http://www.android123.com.cn/kaifafaq/487.html 一文里面包含两种方法。
缩略图ThumbnailUtils类 - Android2.2新增类
从Android
2.2开始系统新增了一个缩略图ThumbnailUtils类,位于framework的android.media.ThumbnailUtils位
置,可以帮助我们从mediaprovider中获取系统中的视频或图片文件的缩略图,该类提供了三种静态方法可以直接调用获取。
static Bitmap createVideoThumbnail(String filePath, int kind)
//获取视频文件的缩略图,第一个参数为视频文件的位置,比如/sdcard/android123.3gp,而第二个参数可以为MINI_KIND或
MICRO_KIND最终和分辨率有关
static Bitmap extractThumbnail(Bitmap source, int width, int
height, int options) //直接对Bitmap进行缩略操作,最后一个参数定义为OPTIONS_RECYCLE_INPUT
,来回收资源
static Bitmap extractThumbnail(Bitmap source, int width, int height) // 这个和上面的方法一样,无options选项
最后Android开发网再次提醒大家,ThumbnailUtils类是API Level从8或更高才开始支持的。
intent调用代码总结的更多相关文章
- 安卓 通过intent调用系统文件管理器打开指定路径目录
安卓 通过intent调用系统文件管理器打开指定路径目录 转 https://blog.csdn.net/qq_34161388/article/details/78586247 当我们知道 ...
- android intent调用系统camera
利用android的camera通常有两种方式:利用intent调用系统的camera,或者结合surfaceview实现自己定制的camera.先分别对这两种方法说明如下: 一.使用系统自配的cam ...
- 分享:根据webservice WSDL地址自动生成java调用代码及JAR包
分享:根据webservice WSDL地址自动生成java调用代码及JAR包使用步骤:一.安装java 并配置JAVA_HOME 及 path二.安装ANT 并配置ANT_HOME三.解压WsdlT ...
- phpcms v9最常用的22个调用代码
新源网络工作室友情总结phpcms v9最常用的22个调用代码: 调用最新文章,带所在版块{pc:get sql="SELECT a.title, a.catid, b.catid, b.c ...
- phpcms v9 模板调用代码大全
另:每个栏目会对应当前所选模型的三个模板文件: 这些模板文件所在位置:phpcms/templates/default/content/ 目录下,如果想修改模板文件,只需要到此目录下找到对应的模板文 ...
- 使用soapUI代替WSDL2JAVA生成cxf HTTPS 客户端调用代码
如果直接用cxf下面的wsdl2java生成https服务调用代码,会报https证书的错误.在你不想导入证书的情况下,可以使用soapUI进行客户端代码的生成,步骤如下: 1.设置CXF,如下图: ...
- 【转】AS3多种天气预报调用代码分享
今天我们来介绍利用weather.com.cn上的天气预报功能,这里介绍了大家常用的,其它的大家可以自己去下载. 我们这里的天气预览不需要js来调用,只要用iframe就可以了,更不需要ASP/' t ...
- EzHttp 流传输调用代码示例
EzHttp框架提供的内置接口,用于文件流等传输 流传输调用代码示例 内置接口: public interface IEzStreamHandler { Task<byte[]> GetD ...
- 转载 基于JAVA每月运势api调用代码实例
代码描述:基于JAVA每月运势api调用代码实例 接口地址:http://www.juhe.cn/docs/api/id/58 原文链接:http://outofmemory.cn/code-snip ...
随机推荐
- PriorityQueue实现大顶堆
在做一道算法时需要使用大顶堆,所以查了一下记录. 使用PriorityQueue实现大顶堆 PriorityQueue默认是一个小顶堆,然而可以通过传入自定义的Comparator函数来实现大顶堆.如 ...
- Oracle PL/SQL学习之基础篇(2)--例外
1.例外分类:系统例外.自定义例外 (1)系统例外,参见相关API文档 (2)自定义例外 定义自己的例外:就像自定义变量一样,类型为exception 抛出例外:使用raise抛出自定义例外 set ...
- MySQL 5.7.14 win10安装
1. 下载: http://dev.mysql.com/downloads/mysql/
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用自定义类
1.新建空Qt工程 2.新建C++类HelloQt 3.新建ui文件,添加部件,重命名主窗体(对话框)类名HelloQt,构建生成ui头文件 4.修改头文件helloqt.h #ifndef HELL ...
- 机器学习中规范化项:L1和L2
规范化(Regularization) 机器学习中几乎都可以看到损失函数后面会添加一个额外项,常用的额外项一般有两种,一般英文称作ℓ1-norm和ℓ2-norm,中文称作L1正则化和L2正则化,或者L ...
- 机器学习入门学习笔记:(一)BP神经网络原理推导及程序实现
机器学习中,神经网络算法可以说是当下使用的最广泛的算法.神经网络的结构模仿自生物神经网络,生物神经网络中的每个神经元与其他神经元相连,当它“兴奋”时,想下一级相连的神经元发送化学物质,改变这些神经元的 ...
- LeetCode【第1题】Two Sum
准备刷一刷LeetCode了. 题目: ''' Given an array of integers, return indices of the two numbers such that they ...
- 表单提交.serialize()方法
html中<form id="myForm" action="..." method='POST'> <div><input ty ...
- [Codeforces Round#488]Div.2
总结 这是我无聊透顶肝到三点半的一场 cf ,结果还真够无聊的 这套题涵盖了英语题,语文题,模拟题.注重考查了选手的英语素养能力,语文阅读能力和精湛的模拟和枚举能力.是不可多得的一套好题. 没什么单独 ...
- asp.net web api 跨域,带cookie
官网上有一个介绍 http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api 但是只支 ...