0
public class MyObject implements Parcelable{
    Bitmap image;
    String title;

   @Override
   public int describeContents() {
      return 0;
   }

I dont understand how to make parcelable right yet

@Override
public void writeToParcel(Parcel dest, int flags) {

}

Also I use ImageTextAdapter and store my objects in ArrayList

Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
Chickin Nick
  • 517
  • 1
  • 6
  • 21

1 Answers1

1

Write Bitmap to parcel:

ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
parcel.writeInt(byteArray.length);
parcel.writeByteArray(byteArray);

Read bitmap from parcel:

int length = parcel.readInt();
byte[] byteArray = new byte[length];
parcel.readByteArray(byteArray);
image = BitmapFactory.decodeByteArray(byteArray, 0, length);
Vladyslav Matviienko
  • 10,610
  • 4
  • 33
  • 52