I have the following problem:
First activity
The android camera opens and the user can take a picture. After the picture is taken, the second action starts.
Second activity
In this exercise, the user has the opportunity to view the photo. To do this, I get an image from the first action, for example:
Bundle extras = getIntent().getExtras();
and I create the following bitmap:
BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 5; options.inDither = true; byte[] imageData = extras.getByteArray("imageData"); myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length, options); Matrix mat = new Matrix(); mat.postRotate(90); bitmapResult = Bitmap.createBitmap(myImage, 0, 0, myImage.getWidth(), myImage.getHeight(), mat, true);
The bitmap of the result is stored in sdcard and before leaving this activity, I process the bitmap to avoid the memory problem:
bitmapResult.recycle(); bitmapResult=null;
After that, we go to step 3.
Third activity
In this exercise, the user can see an image of different sizes. Image taken from sdcard .
The big problem is when the user clicks the back button, it is taken from activity three to action two , but my application crashes because it is trying to do operations on bitmap that has been recycled.
And if I donโt recycle the bitmap in the second action, I get an OutOfMemeory Exception when I go up and down my application several times.
Any ideas?