Android异常--Parcelable encountered IOException writing serializable object

异常:

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 intent = getIntent();
        if (intent == null){
            return;
        }
        //得到商品信息
        product_id =intent.getIntExtra("product_id",-1);
        productModel_out  = (ProductModel_out) intent.getSerializableExtra("product");

实体类:
public class ProductModel_out implements Serializable {


    private  int Id;
    private ArrayList BuyDeputeList = new ArrayList<>();
    private ArrayList SellDeputeList = new ArrayList<>();
}


问题出现原因:

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

问题解决:

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






你可能感兴趣的:(Android异常--Parcelable encountered IOException writing serializable object)