For my Android application, I get several unmarshalling errors although I think I\'ve done everything that is needed to properly save and load objects via Parcelable>
By the look of it, the createFromParcel
and newArray
should be overridden like this:
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public MyObject createFromParcel(Parcel in) {
MyObject myObj = new MyObject();
myObj.intArray = in.readIntArray(...);
myObj.intValue = in.readInt(...);
// ....
// IN THE SAME ORDER THAT IS WRITTEN OUT AS PER writeToParcel!
//
return myObj;
}
@Override
public MyObject[] newArray(int size) {
return new MyObject[size];
}
};
Edit:
I forgot to mention that for the above to work, there should have been an empty constructor!
public MyObject(){}