I have two classes that implement Parcelable:
public class A implements Parcelable {
private List<B> bList;
... //everything else omitted
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeTypedList(this.bList);
}
}
and then
public class B implements Parcelable {
private A a;
... //everything else omitted
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.a, flags);
}
}
In other words A
has a list of B
objects and each B
holds a reference to the A
object.
However I've just noticed a situation where during a save instance state call, the app blows up the stack because I suspect it's recursively calling these Parcel writing functions over and over again between the two.
Is there any way to write these to the Parcel without blowing up the stack?