Possible Duplicate:
Android: Strange out of memory issue while loading an image to a Bitmap object
OutOfMemoryError: bitmap size exceeds VM budget :- Android
I know that there are many topics about this allready, but whatever I try it doesn't seem to work.
I've tried several onDestroy tricks including recycling the bitmap, putting it to null, etc etc. Not sure if my code is any different than other situations? It kind of seems that way... I'm using the TouchImageView extend so I can use pinch zoom so maybe that makes it more complex?
Anyway here's my code. Could anyone please point out how I can fix this (btw without downscaling the bitmap) please?
public class PageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.page);
Intent parent = getIntent();
int pagenumber = parent.getIntExtra("pagenumber", 1);
int resID = getResources().getIdentifier("page"+pagenumber , "drawable", getPackageName());
TouchImageView img = new TouchImageView(this);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resID);
img.setImageBitmap(bitmap);
img.setMaxZoom(4f);
LinearLayout rootview = (LinearLayout) findViewById(R.id.RootView);
rootview.addView(img);
}
}