【发布时间】:2012-07-13 15:42:46
【问题描述】:
我已尝试在 stackoverflow 上找到的所有解决方案来解决此问题,但徒劳无功。在运行以下代码时,mAlbumPhotoUri 是 Uri 类型的“/mnt/sdcard/photo/1342147146535.jpg”。 file.exists() 表示该文件存在,但执行最后一行代码后,resultBitmap 为空。
我做错了什么?
File file = new File(mAlbumPhotoUri.toString());
if(file.exists()){
Toast.makeText(this, "File exists in /mnt", Toast.LENGTH_LONG);}
else {
Toast.makeText(this, "File NOT exists in /mnt", Toast.LENGTH_LONG);}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; //only get the size of the bitmap
if (resultPhotoBitmap != null) {
resultPhotoBitmap.recycle();
}
String fname=new File(mAlbumPhotoUri.toString()).getAbsolutePath();
resultPhotoBitmap = BitmapFactory.decodeFile(fname, options);
【问题讨论】:
-
对不起,我忘了提.. 这是安卓系统。
-
您是否尝试过在文件资源管理器中打开文件或以某种方式检查内容?
标签: android bitmapfactory