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 ...
随机推荐
- glibc strlen delphi pascal
From: Will DeWitt Jr. Subject: Fast strlen routine? NewsGroup: borland.public.delphi.language.basm D ...
- CSS去除链接虚线(兼容IE6、IE7)
在css里加入以下代码: a{ hide-focus: expression( this.hideFocus=true ); outline: none;}
- IIS配置(安装IIS、.Net、更改IIS Log目录位置)
#安装IIS..NetFramework 3.5 Import-Module servermanager Get-WindowsFeature web-* | ? {$_.Name -ne " ...
- 玩转iOS开发 - 多线程开发
前言 本文主要介绍iOS多线程开发中使用的主要技术:NSOperation, GCD. NSThread, pthread. 内容依照开发中的优先推荐使用的顺序进行介绍,涉及多线程底层知识比較多的NS ...
- UVA 674 Coin Change (DP)
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make c ...
- grumble.js
grumble.js是一个jQuery插件.它提供了气泡提示框功能. 我们可以自定义气泡框的角度,大小,内容,以及回调方法等. 用法很简单: $('#grumble1').grumble( { tex ...
- iOS开发——实战OC篇&环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)
环境搭建之StoryBoard(玩转UINavigationController与UITabBarController) 研究了这么就IOS开发,都没有所处一个像样或者自己忙一点的项目.最近自 ...
- 在ascx中调用另一个ascx的写法
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- Qt 类外调用一个 private slots 函数
MainWindow中 private slots 函数 void print_on_log(QString strtemp);输出一个字符串到编辑窗口中 class MainWindow:publi ...
- mysql数据类型区别
create table t1(c1 float(10,2), c3 decimal(10,2)); insert into t1 values(1234567.23, 1234567.23,1234 ...