Class not found when Unmarshalling Android Intent Parcelable

强颜欢笑 提交于 2019-11-29 05:37:13

You should try replacing this.choices = parcel.readArrayList(null); by this.choices = parcel.readArrayList(Choices.class.getClassLoader());

Hope this helps

You should set the ClassLoader. Try this:

public Question (Parcel parcel) {
    this.id = parcel.readString();
    this.text = parcel.readString();
    this.image = parcel.readString();
    this.choices = parcel.readTypedList(Choices.class.getClassLoader());
}

Also you can try to read and write a typed List instead of an ArrayList:

public Question (Parcel parcel) {
    this.id = parcel.readString();
    this.text = parcel.readString();
    this.image = parcel.readString();
    this.choices = new ArrayList<Choices>();
    parcel.readArrayList(this.choices, Choices.Creator);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!