I\'d like to make class A Parcelable.
public class A {
public String str;
public ArrayList list;
}
This is what I\'ve come
At Write to parcel
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(name); //if String
parcel.writeTypedList(assignedEmployees); //if List with custom class, eg. List assignedEmployees
parcel.writeParcelable(checkin,i); //if custom class, eg. Checkin checkin;
}
At Constructor for reading it back
protected A(Parcel in) {
name = in.readString();
assignedEmployees = in.createTypedArrayList(AssignedEmployee.CREATOR);
checkin = in.readParcelable(Checkin.class.getClassLoader());
}
where AssignedEmployee, Checkin where custom classes and it should implement Parcelable.