Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass bitmap from one activity to another

Tags:

android

bitmap

i have bitmap in ActivityA i want to pass the bitmap from here to ActivityB, i googled for this. when i use this

Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("BitmapImage", bitmap);

for getting

Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");

i am getting this error !!! FAILED BINDER TRANSACTION !!! . how can i solve this problem.

like image 810
NagarjunaReddy Avatar asked Nov 24 '11 09:11

NagarjunaReddy


1 Answers

Your code is correct for putting bitmaps into the extras and works fine for me with small images. But it seems that there is a limit for the size of the Parcelable extra. See http://groups.google.com/group/android-developers/browse_thread/thread/7322a84adcfee567?pli=1.

You might want to store the image first and only hand over the URI to the store location.

Edit: Using a public static field for the bitmap as suggested by udaykiran violates so many OO principles I don't even know where to start.

like image 78
ct_rob Avatar answered Nov 09 '22 21:11

ct_rob