how to serialize for android.location class?

后端 未结 3 1754
青春惊慌失措
青春惊慌失措 2021-01-18 10:34

I\'m trying to serialize my location class (using android.location class)

but, it gives me an error!

11-21 21:25:37.337: W/System.err(3152): java.io.         


        
3条回答
  •  情歌与酒
    2021-01-18 11:10

    You can not make a non-serializable class serializable just implementing the Serializable interface. A serializable class must inherit from a serializable class (if an inherited class) and have all its attributes serializable themselves.

    All subtypes of a serializable class are themselves serializable. http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html

    However, if you want to serialize a Parcelable class it is still possible, but surely it would not be a good practice.

提交回复
热议问题