I\'m new to android. I want to pass bitmap into Bundle. But I can\'t find any solution for it. Actually, I\'m confused. I want to display an image in a Dialog fragment. But I do
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);