Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.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 FileNotFound和NullPointerException_Android - Fatal编程技术网

Android BitmapFactory FileNotFound和NullPointerException

Android BitmapFactory FileNotFound和NullPointerException,android,Android,此外,此错误仅显示一次,即首次从服务器加载数据时。从那以后,我再也看不到这个错误。 显示错误的行是 E/BitmapFactory(31986): Unable to decode stream: java.io.FileNotFoundException: /data/data/com.example.xyz/files/img/l/image_00tt.png: open failed: ENOENT (No such file or directory) D/AndroidRun

此外,此错误仅显示一次,即首次从服务器加载数据时。从那以后,我再也看不到这个错误。 显示错误的行是

E/BitmapFactory(31986): Unable to decode stream: java.io.FileNotFoundException:
    /data/data/com.example.xyz/files/img/l/image_00tt.png: open failed: ENOENT (No such file or 
directory)
D/AndroidRuntime(31986): Shutting down VM
W/dalvikvm(31986): threadid=1: thread exiting with uncaught exception (group=0x41849da0)
E/AndroidRuntime(31986): java.lang.NullPointerException
E/AndroidRuntime(31986):    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:704)
E/AndroidRuntime(31986):    at    com.example.xyz.Customlistadapter.getView(Customlistadapter.java:46)

有人能帮我捕获位图的这两个错误吗?即FileNotFoundException和NullPointerException?

我做了以下操作以避免NullPointerException

Bitmap bitmap=Bitmap.createScaledBitmap(BitmapFactory.decodeFile(Image[position]), 32, 32, true);
if(BitmapFactory.decodeFile(Image[position])!=null)
{
    Bitmap bitmap=Bitmap.createScaledBitmap(BitmapFactory.decodeFile(Image[position]), 32, 32, true);
    imageView.setImageBitmap(bitmap);
}
else
{
    Log.d("TAG", "unable to decode");
}