Unable To Marshal Value On Serializable Data
I get the following error when trying to pass a HashMap to my MainActivity class (TabooCards implements Serializable). I read around here that HashMap is serializable, and that any
Solution 1:
Use Parcelable and not Serializable. Read this tuto
This is how your class should be :
import android.os.Parcel;
import android.os.Parcelable;
publicclassTabooCardimplementsParcelable {
publicstatic final Parcelable.Creator<TabooCard> CREATOR = newParcelable.Creator<TabooCard>()
{
@OverridepublicTabooCardcreateFromParcel(Parcel source)
{
returnnewTabooCard(source);
}
@OverridepublicTabooCard[] newArray(int size)
{
returnnewTabooCard[size];
}
};
String mainWord, taboo1, taboo2, taboo3, taboo4, taboo5;
publicTabooCard() {
this("Main Card", "Taboo 1", "Taboo 2", "Taboo 3", "Taboo 4", "Taboo 5");
}
publicTabooCard(String mainword, String taboo1, String taboo2, String taboo3, String taboo4, String taboo5) {
setMainWord(mainword);
setTaboo1(taboo1);
setTaboo2(taboo2);
setTaboo3(taboo3);
setTaboo4(taboo4);
setTaboo5(taboo5);
}
publicTabooCard(Parcelin) {
setMainWord(in.readString());
setTaboo1(in.readString());
setTaboo2(in.readString());
setTaboo3(in.readString());
setTaboo4(in.readString());
setTaboo5(in.readString());
}
@Overridepublic int describeContents() {
return0;
}
@OverridepublicvoidwriteToParcel(Parcel dest, int flags) {
dest.writeString(mainWord);
dest.writeString(taboo1);
dest.writeString(taboo2);
dest.writeString(taboo3);
dest.writeString(taboo4);
dest.writeString(taboo5);
}
Post a Comment for "Unable To Marshal Value On Serializable Data"