views:

77

answers:

1

I'm implementing Parcelable class that has another Parcelable insde.

In OuterParcelable class:

@Override
public void writeToParcel(Parcel dest, int flags) {
    Bundle tmp = new Bundle();

    tmp.putParcelable("innerParcelable", mParcelable);
    dest.writeBundle(tmp);

and then:

public OuterParcelable(Parcel parcel) {
    super();

    Bundle b = parcel.readBundle();
    mParcelable = b.getParcelable("innerParcelable");

and:

    public OuterParcelable createFromParcel(Parcel in) {
        return new OuterParcelable(in);
    }

When I recreate object using above code I get:

 08-18 17:13:08.566: ERROR/AndroidRuntime(15520): Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: my.package.InnerParcelable
A: 

I've abandoned idea of implementing Parcelable and ended up with constructor that takes Bundle as a parameter and method writeToBundle that return Budle used later with constructor.

pixel