I\'m trying to parcel an object which contains some string/int variables and an object variable. The strings and int\'s are working, but not the nested object. I understand I wo
I solved this by changing the order in which I write/read from the Parcel. I made the dest.writeParcelable(otherClass, flags);
and the otherClass = (OtherClass) in.readParcelable(OtherClass.class.getClassLoader());
calls to be the first in their methods and it started working. Is that an issue?
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(otherClass, flags);
dest.writeString(name);
dest.writeInt(id);
}
private MyClass(Parcel in) {
otherClass = (OtherClass) in.readParcelable(OtherClass.class.getClassLoader());
name = in.readString();
id = in.readInt();
}