views:

141

answers:

1

Hi All, I'm trying to create class with generics that will have ability to serialize its state using Parcelable interface. The problem is that class has to contain constructor with single parameter - Parcel, but in my case I need to create class with additional parameters. Besides, Parcelable.Creator doesn't allow to use generics.

Here is an example:

public class Sample<T> {

...

public Sample(Context ctx, SomeInterface iface, Parcel parcel) {...}

...

}

What is the best practice to do it?

+1  A: 

Already found the solution - I moved all members related to object state into separate Parcelable class and added the following constructor:

public Sample(..., ParcelableState state)

Artem