Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 同一路径的BitmapFactory.decodeFile返回null_Android_Image_Bitmap_Decode - Fatal编程技术网

Android 同一路径的BitmapFactory.decodeFile返回null

Android 同一路径的BitmapFactory.decodeFile返回null,android,image,bitmap,decode,Android,Image,Bitmap,Decode,问题是,即使路径相同,但decodefile函数有时在调用该函数时返回null public static Bitmap lessResolution(String filePath, int width, int height) { int reqHeight = width; int reqWidth = height; BitmapFactory.Options options = new BitmapFactory.Options(); options.

问题是,即使路径相同,但decodefile函数有时在调用该函数时返回null

public static Bitmap lessResolution(String filePath, int width, int height) {
    int reqHeight = width;
    int reqWidth = height;
    BitmapFactory.Options options = new BitmapFactory.Options();

    options.inJustDecodeBounds = true;
    //BitmapFactory.decodeFile(filePath, options);

    options.inSampleSize = calculateInSampleSize(options, reqWidth,
            reqHeight);

    options.inJustDecodeBounds = false;

    Bitmap b = BitmapFactory.decodeFile(filePath, options);

    Log.d("test1","f:" + filePath);
    Log.d("test1","b:" + b);

    return b;
}
在成功案例中:

02-10 09:28:23.554 22444-22444/? D/test1: f:/storage/emulated/0/MyApp/1486690065.jpg
02-10 09:28:23.554 22444-22444/? D/test1: b:android.graphics.Bitmap@8756c
在失败的情况下:

02-10 09:29:22.425 22444-22444/? D/test1: f:/storage/emulated/0/MyApp/1486690065.jpg
02-10 09:29:22.425 22444-22444/? D/test1: b:null

非常感谢您的帮助。

我有一个类似的代码正在运行,但是使用了BitmapFactory.decodeFile(文件路径,选项);未注释的汉克斯。取消注释将给出相同的结果