我正在开发相机应用程序。第一次,如果我捕获图像,它可以正常工作,但是如果我再次拍照,则抛出错误
和应用程序关闭..如何处理该如何清除堆和虚拟机?
请帮忙..
提前致谢..
最佳答案
我找到了答案。
我使用以下代码:
BitmapFactory.Options bfOptions=new BitmapFactory.Options();
bfOptions.inDither=false; //Disable Dithering mode
bfOptions.inPurgeable=true; //Tell to gc that whether it needs free memory, the Bitmap can be cleared
bfOptions.inInputShareable=true; //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
bfOptions.inTempStorage=new byte[32 * 1024];
CameraTricks.SdCardImage= BitmapFactory.decodeFile(CameraTricks.yu,bfOptions);
CameraTricks.yu is my path to bitmap