After strugling for days with this problem I finally found a way to do it.
Q: How to show a large bitmap without carshing the application on VM budget by turning the phone around or open the Activity the second time?
Always call bitmap.recycle() method after using Bitmaps. Calling GC is not the solution, it is not guaranteed that it will be called. And also, without calling recycle method, the bitmap will not get freed after its use.
options.inScaled = true;
options.inPurgeable = true;
options.inInputSharable = true;
If this also doesnt solve your problem, try ussing WeakReferences: Bitmap, Bitmap.recycle(), WeakReferences, and Garbage Collection
If this also does not work, then there might be some other memory leak in your code. Use MAT in eclipse to find out the memory leak from your code.
You have to downscale the picture a bit before displaying it using:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 3; // If number equals 3, it is only showing one third of all pixels. May crash if you are using 2, but 2 works in most cases.
Bitmap bMap = BitmapFactory.decodeFile((sdcard/exaple_file)), options);
Drawable d =new BitmapDrawable(bMap);
myLinearLayout.setBackgroundDrawable(d);
And in onPause:
@Override
protected void onPause() {
super.onPause();
System.gc();
}
// Some say that you should never call system gc your self, but for me it helps with stability.
This solved my problem, but may not be 100% optimal. But it stops the App crash on VM budget.