更新时间: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();