Serialize KeyguardLock
I am writing an android application and I need to have two classes use the same KeyguardLock object but I am experiencing extreme difficulty in sharing (via serialization) that object. I have tried using the serialization stackoverflo开发者_运维问答w example link but that didn't work at all. I get a "not serializable" IO exception trying to save the object. I have also tried using JSONObject.
Any ideas? Has anyone run into a similar problem?
Why are you trying to serialize it? A object can only be serialize if it implements Serializable
which KeyguardLock
doesn't.
If you're trying to pass it around Activities, either create a custom Application
object and store it there. Or use a public static
variable in a class and access it via that. The static variable is probably the better option for this.
精彩评论