Android异常--Parcelable encountered IOException writing serializable object

来源:互联网 发布:双缝实验 知乎 编辑:程序博客网 时间:2024/05/14 23:57

异常:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object

出现地方:

intent发送:

            Intent intent = new Intent(getActivity(), StockDetailActivity.class);            ProductModel_out product = (ProductModel_out)parent.getItemAtPosition(position);            intent.putExtra("product",product);            startActivity(intent);

        //得到上个页面传递过来的数据        Intent intent = getIntent();        if (intent == null){            return;        }        //得到商品信息        product_id =intent.getIntExtra("product_id",-1);        productModel_out  = (ProductModel_out) intent.getSerializableExtra("product");

问题出现原因:

productModel_out我虽然是实现了serialzable接口,但是
productModel_out类中我还嵌套了其他自定义的实体类,那个实体类没有实现Serialzable接口,所以会出现这类类型转换的异常.

问题解决:

productModel_out类中所有嵌套的实体类都实现SerialZable接口

阅读全文
0 0
原创粉丝点击