How to send the bitmap into bundle

No need to convert bitmap to byte array. You can directly put bitmap into bundle. Refer following code to put bitmap into bundle.

bundle.putParcelable("BitmapImage",bitmapname);

Get bitmap from Bundle by following code

Bitmap bitmapimage = getIntent().getExtras().getParcelable("BitmapImage");

First of all convert it to a Byte array before adding it to intent, send it out, and decode.

//Convertion to byte array

  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
  byte[] byteArray = stream.toByteArray();

Bundle b = new Bundle();
b.putByteArray("image",byteArray);


  // your fragment code 
fragment.setArguments(b);

get Value via intent

byte[] byteArray = getArgument().getByteArrayExtra("image");
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);

Tags:

Android

Bitmap