How to use Parcelable if the class requires additional parameters in construction
I am trying to create a class with generics that will be able to serialize its state using the Parcelable interface. The problem is that the class should contain a constructor with only one parameter - Parcel, but in my case I need to create a class with additional parameters. Also, Parcelable.Creator does not allow generics.
Here's an example:
public class Sample<T> {
...
public Sample(Context ctx, SomeInterface iface, Parcel parcel) {...}
...
}
What's the best practice?
+2
a source to share