A full size picture took by camera is pretty large. Let's say maybe 4 million pixels, if you are using RGB8888 to read as bitmap, it will cost about 16mb. If you want to load 2 pictures at the same time, it is likely to out of memory.
There are several ways could help.
- Read the bitmap with a sample size, which will lower the resolution of the bitmap. See this page for details.
- Use RGB565 instead of RGB8888 to read the bitmap. Since your bitmap will be opaque, the alpha channel will be useless.
- Recycle the old bitmap before creating a new one. This is what you can try fist.
See the sample code below.
ImageView mImage = xxx;
BitmapDrawable drawable = (BitmapDrawable) mImage.getDrawable();
if(drawable != null && drawable.getBitmap() != null){
drawable.getBitmap().recycle();
mImage.setImageDrawable(null);
}
// set new bitmap here.