且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

BitmapFactory.de codeFILE返回null甚至存在图像

更新时间:2022-11-16 11:05:49

如果在 NullPointerException异常直接是在这条线:

If the NullPointerException is directly on this line:

i.setImageBitmap(BMAP);

i.setImageBitmap(bMap);

那么你的问题是, I 。既然你打电话setImageBitmap(),我猜测 I 的ImageView - 确保你的 findViewById()调用工作。

Then your problem is that i is null. Given that you're calling setImageBitmap(), I am guessing that i is an ImageView -- make sure your findViewById() call is working.

此外,您应该使用下列内容来获得 FNAME

Also, you should use the following to get fname:

字符串FNAME =新的文件(getFilesDir(),test.png),getAbsolutePath();

String fname=new File(getFilesDir(), "test.png").getAbsolutePath();