Sending Nested Parcelable with Intent

前端 未结 3 1299
粉色の甜心
粉色の甜心 2021-01-21 10:31

I am trying to send a Parcelable object which also contains another Parcelable object with Intent. However, I am getting NullPointer Exception. Could you please tell me where I

3条回答
  •  自闭症患者
    2021-01-21 11:38

    you have problem with parsing the arraylist... do these changes..

    private A (Parcel in){
            in.readTypedList(this.var, B.CREATOR);
    }
    

    to

    this.var=in.readArrayList(B.class.getClassLoader());
    

    and

    public void writeToParcel(Parcel dest, int flags) {
            dest.writeTypedList(this.var);
    }
    

    to

    dest.writeList(this.var);
    

提交回复
热议问题