“BadParcelableException: ClassNotFoundException when unmarshalling ” while using Parcel.read method that has a ClassLoader as argument

前端 未结 4 1709
我寻月下人不归
我寻月下人不归 2020-12-02 10:16

Given a custom class org.example.app.MyClass implements Parcelable, I want to write a List to a Parcel. I did the marshalling with

4条回答
  •  隐瞒了意图╮
    2020-12-02 10:55

    I believe a more correct form of this would be:

    List myclassList = new ArrayList();
    parcel.readList(myclassList, MyClass.class.getClassLoader());
    

    Because here you are explicitly using the class loader for the List's generic type.

提交回复
热议问题