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?
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)
精彩评论