读取SD卡的权限

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

系统跳转
startActivityForResult(new Intent(Intent.ACTION_PICK).setType("image/*"),PICK_CODE);

回来后取得图片
 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==PICK_CODE){
if(data!=null){
// 获取图片地址
//
Cursor cursor=getContentResolver().query(data.getData(), null, null, null, null);
cursor.moveToFirst();
currentPhotoStr=cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA));
cursor.close();
// 压缩图片
resizePhoto();
imageView.setImageBitmap(photoImage);
}
}
} 压缩图片
private void resizePhoto() {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inJustDecodeBounds=true;
BitmapFactory.decodeFile(currentPhotoStr,options);
double ratio=Math.max(options.outWidth*1.0d/1024f,options.outHeight*1.0d/1024f);
options.inSampleSize=(int)Math.ceil(ratio);
options.inJustDecodeBounds=false;
photoImage= BitmapFactory.decodeFile(currentPhotoStr, options);
}

提取SD卡中的图片的更多相关文章

  1. Android获取SD卡中选中图片的路径(URL)

    最近在做一个图片上传的功能,需要提供上传图片在SD卡中的路径,在网上看了些例子,改改调试成功,代码很简单.其布局文件如下: [html]  view plain copy   <?xml ver ...

  2. android 读取sd卡中的图片

    一.获取读取SD卡的权限 <!--在SDCard中创建与删除文件权限  -->    <uses-permission android:name="android.perm ...

  3. 读取SD卡中的图片

    Touxiang=(ImageView)view.findViewById(R.id.Touxiang); //头像Bitmap bm = BitmapFactory.decodeFile(" ...

  4. BitmapUtil【缩放bitmap以及将bitmap保存成图片到SD卡中】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 用于缩放bitmap以及将bitmap保存成图片到SD卡中 效果图 代码分析 bitmapZoomByHeight(Bitmap s ...

  5. Android_(控件)使用Gallery浏览手机上SD卡中图片

    运行截图: (发现后面两张照片是自己自拍,大写的尴尬对图片进行涂鸦了!!!) 程序结构: <?xml version="1.0" encoding="utf-8&q ...

  6. 【Android 界面效果30】Android中ImageSwitcher结合Gallery展示SD卡中的资源图片

    本文主要是写关于ImageSwitcher结合Gallery组件如何展示SDCard中的资源图片,相信大家都看过API Demo 中也有关于这个例子的,但API Demo 中的例子是展示工程中Draw ...

  7. 【记录】尝试用android-logging-log4j去实现log输出内容到sd卡中的文件的功能

    [背景] 折腾: [记录]给Android中添加log日志输出到文件 期间,已经试了: [记录]尝试用android中microlog4android实现log输出到文件的功能 但是不好用. 然后就是 ...

  8. Android中使用SQLiteOpenHelper管理SD卡中的数据库

    使用Android中自带的SQLiteOpenHelper可以完成数据库的创建与管理,但有两点局限: (1)数据库创建在内存卡中,大小受限,创建位置位于/data/data/应用程序名/databas ...

  9. 与众不同 windows phone (37) - 8.0 文件系统: StorageFolder, StorageFile, 通过 Uri 引用文件, 获取 SD 卡中的文件

    [源码下载] 与众不同 windows phone (37) - 8.0 文件系统: StorageFolder, StorageFile, 通过 Uri 引用文件, 获取 SD 卡中的文件 作者:w ...

随机推荐

  1. Tomcat_启动多个tomcat时,会报StandardServer.await: Invalid command '' received错误

    解决方案如下:将tomcat下的server.xml文件中的端口有问题,修改规则按以下标准显示“http的端口修改为6000 to 6800之间,shutdown的端口修改为3000 to 3300之 ...

  2. Java生成动态GIF图片

    写selenium自动化时,为了查看运行效果,后给浏览器截图,想到可以生成gif图片来快速预览.看到已经有人实现了,直接拿过来. 共涉及到三个java文件,分别是NeuQuant.java,LZWEn ...

  3. IO流,File类的测试........课堂加总结

    package liu0926; import java.io.File; import java.io.IOException; public class Text01 { public stati ...

  4. $.ajax用法与举例

    下面是一段比较常用到的 $.ajax 方法: $.ajax({ type:'GET', url:'http://www.phpernote.com/jquery.php', data:{usernam ...

  5. spring security使用数据库资源

    国内对权限系统的基本要求是将用户权限和被保护资源都放在数据库里进行管理,在这点上Spring Security并没有给出官方的解决方案,为此我们需要对Spring Security进行扩展.. 数据库 ...

  6. JSON与DataTable(DataSet)相互转化

    public static string CreateJsonParameters(DataTable dt)        {            /* /******************** ...

  7. boostrap折叠,jquery ui accordion同时打开多个标签

    http://caibaojian.com/bootstrap/javascript.html http://www.w3cschool.cc/jqueryui/example-accordion.h ...

  8. C++中嵌入Lua脚本环境搭建

    第一步(环境准备工作): 工具: ●LuaForWindows_v5.1.4-46.exe傻瓜式安装. 作用:此工具可以在windows环境下编译运行Lua脚本程序.安装完成后会有两个图标:Lua和S ...

  9. Customizing the Editor

    Use the General, Text Editor, Options Dialog Box to customize the appearance and functionality of th ...

  10. javaWeb中servlet开发(4)——servlet跳转

    servlet跳转 1.跳转类型 客户端跳转:跳转后地址栏改变,无法传递request范围内属性,是在所有的操作都执行完毕之后才发生跳转的操作,跳转语法是,response.sendRedict() ...