Android 异常 UncaughtException detected: java.lang.RuntimeException: Parcelable encountered IOExcepti

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

出现原因

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

实体类


/**
 * 作者:  pyfysf
 * 

* qq: 337081267 *

* CSDN: http://blog.csdn.net/pyfysf *

* 个人博客: http://wintp.top *

* 时间: 2018/01/2018/1/23 15:07 *

* 邮箱: [email protected] */ 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 进行序列化。

你可能感兴趣的:(Android,异常累计)