BitmapFactory.decodeFile()返回null [英] BitmapFactory.decodeFile() returns null

查看:400
本文介绍了BitmapFactory.decodeFile()返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Android应用,其中您将图像从位置x复制到位置y.复制完成后,我想在ImageView中查看图片. 我知道图像的位置,但是无论如何尝试,都无法创建它的bitmap对象.

I am creating an Android app in which you copy an image from location x to location y. After the copying is complete I would like to see the picture in a ImageView. I know the images location, but no matter what I try I can't create a bitmap object of it.

引起我问题的那一行是:

The line which are causing my problems is this:

BitmapFactory.decodeFile(dir+s);

dir = getCacheDir().getAbsolutePath()+"/images/";

s = file name (eg. 1275123123.jpg)

如果我创建具有相同路径的File对象,并调用f.isFile(),它将返回true.

If I create a File object with the same path, and call f.isFile(), it returns true.

在android或Windows中打开图像都不是问题.

Opening the image in either android or windows are not a problem.

推荐答案

您是否还忘记添加SD卡访问权限READ_EXTERNAL_STORAGE和/或WRITE_EXTERNAL_STORAGE?

Didn't you forget to add SD card access permissions READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE ?

这篇关于BitmapFactory.decodeFile()返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆