【发布时间】:2010-09-24 14:26:03
【问题描述】:
我只是想获取用户选择的图像的路径,然后将其转换为位图。问题是,选择时只有画廊中的一些图像工作(“工作”是指发现它们是存在的文件),而其他人则声称该文件不存在(即使图像正在显示在画廊里?)。更奇怪的是,这似乎并不一致,曾经被认为“存在”的图像现在声称不存在。我的代码如下:
-----意图-----
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, GALLERY_ACTIVITY);
-----onActivityForResult-----
Uri uri = intent.getData();
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(uri,proj,null,null,null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
BitmapFactory.Options opts = new BitmapFactory.Options();<br/>
opts.inSampleSize = 2;<br/>
Bitmap b = BitmapFactory.decodeFile(cursor.getString(column_index),opts);
对此的任何想法将不胜感激,谢谢!
马特。
【问题讨论】:
标签: android image android-intent gallery filenotfoundexception