在常见的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的更多相关文章

  1. android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用

    你是不是很多时候,想从弹出的电话本姓名列表中中查找到某个人,然后再获取该人的详细信息呢? 你是不是想选择从弹出的列表中选择一张图片,然后将其进行进一步的操作呢? 如果,你想,那你是不是很像知道,我们应 ...

  2. android Intent介绍

    Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 ...

  3. android intent和intent action大全

    1.Intent的用法:(1)用Action跳转1,使用Action跳转,如果有一个程序的AndroidManifest.xml中的某一个 Activity的IntentFilter段中 定义了包含了 ...

  4. 系统隐式 Intent

    1. 找出系统中所有视频 private void choiceFile() { Intent intent = new Intent(Intent.ACTION_PICK, android.prov ...

  5. Intent的详细解析以及用法

    Intent的详细解析以及用法      Android的四大组件分别为Activity .Service.BroadcastReceiver(广播接收器).ContentProvider(内容提供者 ...

  6. 我的Android最佳实践之—— 常用的Intent.Action(转)

    1.从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putEx ...

  7. Android开发-API指南-常用Intent

    Common Intents 英文原文:http://developer.android.com/guide/components/intents-common.html 采集(更新)日期:2014- ...

  8. 常见的Activity Action Intent常量

    Intent的中文意思是“意图,目的”的意思,可以理解为不同组件之间通信的“媒介”或者“信使”. 目标组件一般要通过Intent来声明自己的条件,一般通过组件中的<intent-filter&g ...

  9. Intent(二)

    以Android高级编程一书中的一个例子为例: 1, 创建一个ContactPicker项目,其中包含一个ContactPicker Activity package com.paad.contact ...

随机推荐

  1. 记录一些在VPS上折腾的东西

    折腾这些东西,总是要经常借助搜索引擎找答案,找的次数多了,也就烦了,不想总是做重复工作. 所以把做过的一些事情记录一下,加深一下印象. 1.安装python2.7 VPS上面的太老了,之前安装的,过程 ...

  2. BZOJ 2751: [HAOI2012]容易题(easy) 数学

    2751: [HAOI2012]容易题(easy) 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=2751 Description 为了使 ...

  3. UVA 12901 Refraction 几何/大雾题

    Refraction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.a ...

  4. C#利用GDI+绘制旋转文字等效果

    C#中利用GDI+绘制旋转文本的文字,网上有很多资料,基本都使用矩阵旋转的方式实现.但基本都只提及按点旋转,若要实现在矩形范围内旋转文本,资料较少.经过琢磨,可以将矩形内旋转转化为按点旋转,不过需要经 ...

  5. UITableViewController

    UITableViewController 目录 概述 UITableView UITableViewCell 与UITableViewController相关的代理 UITableViewDataS ...

  6. 何查看Tomcat版本信息

    转自:http://dengjianqiang200.blog.163.com/blog/static/65811920094644354148/ 一般来说,在tomcat启动时就会有版本信息,如: ...

  7. Java图片处理(二)图片加水印

    图片加水印,是通过图片重叠绘制实现的.实现代码如下: public static void press(String pressImg, String pressText, String target ...

  8. mybaits 学习

    mybaits  学习(一) 注意:如果建的是web项目,run as java application 参考http://www.cnblogs.com/xdp-gacl/p/4261895.htm ...

  9. solrj-solr Guide 4.7

    solrj是一个很容易使java应用程序和solr进行交互的一个API,solrj隐藏了很多连接Solr的细节,允许你的应用程序使用简单的高级方法和solr互动交流. solrj的核心就是 org.a ...

  10. [WinForm] VS2010发布、打包安装程序(超全超详细)

    1. 在vs2010 选择“新建项目”→“ 其他项目类型”→“ Visual Studio Installer→“安装项目”: 命名为:Setup1 . 这是在VS2010中将有三个文件夹, 1.“应 ...