Android serializable problem

前端 未结 6 713
眼角桃花
眼角桃花 2021-01-04 19:07

I created a class, which has several member variables, all of which are serializable... except one Bitmap! I tried to extend bitmap and implement serializable, not thinking

6条回答
  •  佛祖请我去吃肉
    2021-01-04 19:22

    You can do the serialization by hand by using the following java methods:

    private void writeObject(java.io.ObjectOutputStream out)
    private void readObject(java.io.ObjectInputStream in)
    

    Serialize the bitmap by using getPixels and when you do the deserialization you can use createBitmap to recreate it from scratch.

    You can read about on how to use readObject and writeObject here: http://download.oracle.com/javase/6/docs/api/java/io/Serializable.html

提交回复
热议问题