Jak zrobić klasę z zagnieżdżonymi obiektami Parcelable

Chciałbym uczynić klasę A Parcelable.

public class A {
    public String str;
    public ArrayList<B> list;
}

Oto, co do tej pory wymyśliłem. Jednak zawiesza się przy wyjątku NullPointerException. Problemem są te dwa stwierdzenia:dest.writeList(list); & in.readList(list, this.getClass().getClassLoader());. Nie wiem, co tu robić :(

Klasa A

public class A implements Parcelable {
    public String str;
    public ArrayList<B> list;

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(str);
        dest.writeList(list);
    }

    private A(Parcel in) {
        str = in.readString();
        in.readList(list, this.getClass().getClassLoader());
    }

    public static final Parcelable.Creator<A> CREATOR
            = new Parcelable.Creator<A>() {
        public A createFromParcel(Parcel in) {
            return new A(in);
        }

        public A[] newArray(int size) {
            return new A[size];
        }
    };
}

Klasa B

public class B implements Parcelable {
    public String str;

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(str);
    }

    private B(Parcel in) {
        str = in.readString();
    }

    public static final Parcelable.Creator<B> CREATOR
            = new Parcelable.Creator<B>() {
        public B createFromParcel(Parcel in) {
            return new B(in);
        }

        public B[] newArray(int size) {
            return new B[size];
        }
    };
}

Dziękuję za Twój czas.

questionAnswers(7)

yourAnswerToTheQuestion