Problem serializing Drawable

前端 未结 2 1640
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-22 18:41

I\'ve got a singe object which has three fields: two strings and a Drawable

public class MyObject implements Serializable {

    private static fina         


        
2条回答
  •  时光说笑
    2021-01-22 19:19

    java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable
    

    This message seems pretty clear - the specific drawable instance in the photo field is a BitmapDrawable, which wasn't designed to be serialized. Your class cannot be serialized without dealing with the non-serializable field.

    If you can ensure your class will always have a BitmapDrawable or a Bitmap, you can see this code for an example of how to handle a Bitmap field:

    android how to save a bitmap - buggy code

提交回复
热议问题