I have a parcelable class that is trying to send some camera preview information. So I need to send several byte[] data from one activity to another. I'm using Parcelable
with this code:
public class CameraResult implements Parcelable
{
private byte[] imagesList;
public CameraResult() {}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeByteArray(imagesList);
}
public byte[] getImageList() {
return imagesList;
}
public void setImageList(byte[] results) {
this.imagesList = results;
}
public static final Parcelable.Creator<CameraResult> CREATOR = new Creator<CameraResult>() {
@Override
public CameraResult[] newArray(int size) {
return new CameraResult[size];
}
@Override
public CameraResult createFromParcel(Parcel source) {
CameraResult toReturn = new CameraResult();
int imageListSize = source.readInt();
if (imageListSize != 0)
{
byte[] tempImageList = new byte[imageListSize];
source.readByteArray(tempImageList);
toReturn.setImageList(tempImageList);
}
return toReturn;
}
};
}
This Parcelable
class is working fine. But when I try to send a higher amount of data, the communication Intent
is not working, as I exceed the maximum data size.
I read this link and this other link with some supposed ways to solve my problem. But I would like to know if it's possible to send higher amounts of data using Parcelable
, and if not, which of the mentioned ways is the most adequate one.
Thank you.