Clear Bitmap data and make it null
- by Arun
I am working in an android application and I want to Clear my Bitmap data. The scenario is that I am taking a screen capture of an Widget(Imageview) and I am storing it in a Bitmap. This action comes in a Button click. SO after some time I get a Memory error. So I want to clear the values in the bitmap. So to do that I have done the following code :
The BitMap variable is mCaptureImageBitmap
public void ButtonClick(View v)
{
mCaptureImageBitmap.recycle();
mCaptureImageBitmap=null;
View ve = findViewById(R.id.mainscreenGlViewRelativeLayout);
ve.setDrawingCacheEnabled(true);
mCaptureImageBitmap = ve.getDrawingCache();
}
But I get an error of NullPoint exception. Please help me