I have problem with out of memory with my bitmap. This is code:
Uri bitmapPictureUri = intent.getParcelableExtra(TaskActivity.PHOTO);
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), bitmapPictureUri);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int nh = (int) (bitmap.getHeight() * (512.0 / bitmap.getWidth()));
bitmapPicture = Bitmap.createScaledBitmap(bitmap, 512, nh, true);
picture.setImageBitmap(bitmapPicture);
fileName.setText(tNameText+"_"+getCurrentTime());
everything is ok but when I change orientation I get outOfMemory. How can I solve my problem? I am thinking about softreference but I don't know how can I use it to bitmap. Any idea?
Recycle your bitmap when you start activity
See this also