Parcelable encountered IOException writing serializable object (name = xxx.bean.UserInfoBean)

 

错误信息:

Parcelable encountered IOException writing serializable object (name = xxx.bean.UserInfoBean)

Caused by: java.io.NotSerializableException: xxx.bean.UserInfoBeanData$UserInfoBeanAssets

 

错误位置:

Intent intent = new Intent(context,MainActivity.class);
intent.putExtra("userInfoBean",userInfoBean);
intent.putExtra("loginTokenStr",loginTokenStr);
context.startActivity(intent);
LoginActivity.this.finish();

 

解决方式:

原因是 实体类和它的内部类 都需要进行序列化,否则在使用 Intent 对象进行数据传递的时候会报错

public class UserInfoBeanData implements Serializable {
    private static final long serialVersionUID = 1L;

    private String email;
    private UserInfoBeanAssets assets;
    private String assetsTotal;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public UserInfoBeanAssets getAssets() {
        return assets;
    }

    public void setAssets(UserInfoBeanAssets assets) {
        this.assets = assets;
    }

    public String getAssetsTotal() {
        return assetsTotal;
    }

    public void setAssetsTotal(String assetsTotal) {
        this.assetsTotal = assetsTotal;
    }

    @Override
    public String toString() {
        return "UserInfoBeanData{" +
                "email='" + email + '\'' +
                ", assets=" + assets +
                ", assetsTotal='" + assetsTotal + '\'' +
                '}';
    }


    public class UserInfoBeanAssets implements Serializable {
        private static final long serialVersionUID = 1L;

        private UserInfoBeanUsdt usdt;
        private UserInfoBeanChars chars;

        public UserInfoBeanUsdt getUsdt() {
            return usdt;
        }

        public void setUsdt(UserInfoBeanUsdt usdt) {
            this.usdt = usdt;
        }

        public UserInfoBeanChars getChars() {
            return chars;
        }

        public void setChars(UserInfoBeanChars chars) {
            this.chars = chars;
        }

    }

}

 

 

 

 

 

 

你可能感兴趣的:(错误累积(错题本))