I've got the following class:
public class E implements Parcelable {
@SerializedName("a")
private String a= null;
@SerializedName("b")
private BigDecimal b= null;
@SerializedName("c")
private String c= null;
@SerializedName("d")
private String d= null;
protected E(Parcel in) {
number = in.readString();
expirationYear = in.readString();
expirationMonth = in.readString();
}
public static final Creator<E> CREATOR = new Creator<E>() {
@Override
public E createFromParcel(Parcel in) {
return new E(in);
}
@Override
public E[] newArray(int size) {
return new E[size];
}};
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(number);
dest.writeString(expirationYear);
dest.writeString(expirationMonth);
}
}
How to parcel the data member b? Or better yet, how to parcel boxed types?
As you can see, the writeToParcel method misses the data member b as well as the protected c'tor.
How to use Parcelable on non-primitive types?
A good way to solve this problem (in my opinion) is to create your class extending BigDecimal and implements Parcelable interface on it.