zoukankan      html  css  js  c++  java
  • Android 异常 UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOExcepti

    异常信息:
    UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object

    出现原因

    在Activity之间传递数据的时候,实现Serializable 接口,出现问题。

    实体类

    
    /**
     * 作者:  pyfysf
     * <p>
     * qq:  337081267
     * <p>
     * CSDN:    http://blog.csdn.net/pyfysf
     * <p>
     * 个人博客:    http://wintp.top
     * <p>
     * 时间: 2018/01/2018/1/23 15:07
     * <p>
     * 邮箱:  pyfysf@163.com
     */
    public class GoodsBean implements Serializable {
    
        private String createtime;
        private String images;
        private int clickCount;
        private UniUserBean uniUser;
        private String mobile;
        private String description;
        private int catId;
        private int createid;
        private double price;
        private String name;
        private int id;
        private int status;

    第二个Activity

    
    
        private void exit4Goods(int position) {
            if (mGoodLists != null) {
                //选择商品名称成功
                GoodsBean goodsBean = mGoodLists.get(position);
                Intent data = new Intent();
    
                data.putExtra("goodsBean", goodsBean);
    
                setResult(ConstantValues.ACTIVITY_SELECT_GOODS_SUCCESS_CODE, data);
            }
        }

    第一个Activity

     if (resultCode == ConstantValues.ACTIVITY_SELECT_GOODS_SUCCESS_CODE) {
                //  选择商品成功成功
                if (data != null) {
                    GoodsBean goodsBean = (GoodsBean) data.getSerializableExtra("goodsBean");
                }
            }

    解决方案

    实体类GoodsBean 中引用了UniUserBean ,那么不仅仅只把GoodsBean进行序列化,还要把UniUserBean 进行序列化。

  • 相关阅读:
    DB2数据常用指令
    HTMLParser使用
    面试知识点总结之数据库
    面试知识点总结之算法
    面试知识点总结之操作系统
    面试知识点总结之计算机网络
    面试知识点总结之Java语言
    一个精确匹配的问题
    【转】矩阵求导,矩阵计算
    【转】用C语言扩展Python的功能
  • 原文地址:https://www.cnblogs.com/shaofeer/p/11154360.html
Copyright © 2011-2022 走看看