Intent.ACTION_PICK
在常见的Activity Action Intent常量中,ACTION_PICK android.intent.action.PICK 是“选择数据”的意思,来简单的分享一下我知道的Intent.ACTION_PICK的一些用法:
(一)、调用图库,获取所有本地图片:
Intent imageIntent = new Intent(Intent.ACTION_GET_CONTENT);
imageIntent.setType("image/*");
startActivityForResult(imageIntent, PICK_CODE); //PICK_CODE是常量
(二)、调用本地联系人:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
(三)、调用音乐,获取所有本地音乐文件:
Intent audioIntent = new Intent(Intent.ACTION_GET_CONTENT);
audioIntent.setType("audio/*");
startActivityForResult(audioIntent, PICK_AUDIO);
(四)、调用视频,获取所有本地视频文件:
Intent videoIntent = new Intent(Intent.ACTION_GET_CONTENT);
videoIntent.setType("video/*");
startActivityForResult(videoIntent, PICK_VIDEO);
调用图库处理:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode==PICK_CODE)
{
if (intent!=null)
{
Uri uri=intent.getData();
Cursor cursor=getContentResolver().query(uri, null, null,null, null);
cursor.moveToFirst();
int idx=cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
currentPhotoString=cursor.getString(idx);
cursor.close();
resizePhono();
ivPhoto.setImageBitmap(photoImg);
tvTip.setText("Click Detect==>");
}
}
super.onActivityResult(requestCode, resultCode, intent);
}
/**
* 压缩图片
*/
private void resizePhono() {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds=true;//仅仅加载图片
BitmapFactory.decodeFile(currentPhotoString, options);
double radio=Math.max(options.outWidth*1.0d/1024f, options.outHeight*1.0d/1024f);
options.inSampleSize=(int) Math.ceil(radio);
options.inJustDecodeBounds=false;
photoImg=BitmapFactory.decodeFile(currentPhotoString,options);
}
onActivityResult
Intent.ACTION_PICK的更多相关文章
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
你是不是很多时候,想从弹出的电话本姓名列表中中查找到某个人,然后再获取该人的详细信息呢? 你是不是想选择从弹出的列表中选择一张图片,然后将其进行进一步的操作呢? 如果,你想,那你是不是很像知道,我们应 ...
- android Intent介绍
Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 ...
- android intent和intent action大全
1.Intent的用法:(1)用Action跳转1,使用Action跳转,如果有一个程序的AndroidManifest.xml中的某一个 Activity的IntentFilter段中 定义了包含了 ...
- 系统隐式 Intent
1. 找出系统中所有视频 private void choiceFile() { Intent intent = new Intent(Intent.ACTION_PICK, android.prov ...
- Intent的详细解析以及用法
Intent的详细解析以及用法 Android的四大组件分别为Activity .Service.BroadcastReceiver(广播接收器).ContentProvider(内容提供者 ...
- 我的Android最佳实践之—— 常用的Intent.Action(转)
1.从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putEx ...
- Android开发-API指南-常用Intent
Common Intents 英文原文:http://developer.android.com/guide/components/intents-common.html 采集(更新)日期:2014- ...
- 常见的Activity Action Intent常量
Intent的中文意思是“意图,目的”的意思,可以理解为不同组件之间通信的“媒介”或者“信使”. 目标组件一般要通过Intent来声明自己的条件,一般通过组件中的<intent-filter&g ...
- Intent(二)
以Android高级编程一书中的一个例子为例: 1, 创建一个ContactPicker项目,其中包含一个ContactPicker Activity package com.paad.contact ...
随机推荐
- JavaBean技术
引言: JavaBeans与一般Java类的编写类似. 在JSP页面中要使用JavaBeans,只要在JSP页面中使用JavaBeans的操作标记就可以了. JavaBeans的编写和使用非常简单,下 ...
- Vehicle’s communication protocol
http://www.crecorder.com/techInfo/commuProtocols.jsp COMMUNICATION PROTOCOLS A “communication protoc ...
- C++ CopyFile
复制文件 关键点 CopyFile The CopyFile function copies an existing file to a new file. The CopyFileEx functi ...
- poj 1845(等比数列前n项和及高速幂)
Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13959 Accepted: 3433 Descripti ...
- Maven实战之Quick Start
Introduction Maven是一个异常强大的构建工具,能够帮我们自动化构建过程,从清理.编译.测试到生成报告,再到打包和部署.通过Maven,我们只需要输入简单的命令(如mvn clean i ...
- jquery validate 小demo
方便学习: 直接上代码: ceshi.html: <!DOCTYPE html> <html> <head> <meta http-equiv="C ...
- iOS开发——图层OC篇&UIColor深入研究(CGColor,CIColor)
UIColor深入研究(CGColor,CIColor) 由于跟人比较喜欢研究关于图层与动画方面的技术,正打算看看别人写的好东西,就遇到了好几个问题, 第一:UIClor类方法的使用 就是关于UICo ...
- javascript 基本数据类型
1. javascript 五种基本数据类型 Undefined Boolean Number String Null,Undefined 对应的值只有一个 undefined, Boolean 对 ...
- Golang学习 - io 包
------------------------------------------------------------ 先说一下接口,Go 语言中的接口很简单,在 Go 语言的 io 包中有这样一个 ...
- centos6.4使用man查找命令时,报错No manual entry for xxxx
前提:安装man的命令 yum -y install man 使用man报错 [root@localhost objs]# man fcntlNo manual entry for fcntl[roo ...