Personally, I would avoid keeping that bitmap in memory, otherwise you
are consuming a lot of resources and run the risk of hitting
performance/heap space limitations.

You could use openFileOutput() and getCacheDir() to store the contents
of the Bitmap into a temporary file:
http://developer.android.com/intl/fr/guide/topics/data/data-storage.html#filesInternal

Then pass the path to the file via the Intent.putExtra() mechanism
that you are already using. This way you are only loading the bitmap
into memory when it is needed, solving your problem of transferring it
to the other activity, and ensuring the temporary file is cleaned up
if your app crashes before you have time to delete it.


On Mon, Jun 7, 2010 at 7:24 AM, mike <[email protected]> wrote:
> hi guys,
>
> i have a Bitmap image and i want to forward the bitmap to another
> activity.
>
> i have two activities Activity A and Activity B
>
> this is how i started the Activity B
>
> startActivityForResult(new Intent(Activity A.this, Activity B.class),
> 120);
>
> in activity B
>
>        private void forwardImage(Bitmap bit) {
>                Intent i = new Intent(MMS.this, Compose.class);
>                i.putExtra("MMS", bit);
>                setResult(RESULT_OK, i);
>                finish();
>        }
>
> this is not forwarding to Activity A
> but if i put a String to the intent it'll forward.
>
> this is how i listene to result in Activity A
>
>       �...@override
>        protected void onActivityResult(int requestCode, int resultCode,
> Intent data) {
>                // TODO Auto-generated method stub
>                // super.onActivityResult(requestCode, resultCode, data);
>                switch (resultCode) {
>                case RESULT_OK:
>                        Intent intent = getIntent();
>                        Bitmap bitmap = (Bitmap) 
> intent.getParcelableExtra("MMS");
>
>                        mmsImage.setImageBitmap(bitmap);
>
>                default:
>                        break;
>                }
>
>        }
>
> how can i pass a bitmap
>
> regards,
> Mike
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to