问题描述
我试图实现应用程序序列化的Android意图,通过套接字从客户发送到服务器和反序列化的server.i尝试序列中的客户端的意图与常规的Java序列化API,但在运行时它的说,意图不serializable.is有什么解决办法序列化的意图和反序列化呢?只是我需要一提的是,我用KRYO也为序列化和反序列化,但我再次在反序列化时遇到错误。有没有解决这个?
I'm trying to implement an application to serialize android intent and send it through a socket from client to server and deserialize it on the server.i try to serialize intent in client side with regular java serialization API but in the runtime it's saying that the intent is not serializable.is there any solution to serialize intent and deserialize it? just i need to mention that i used kryo also for serialization and deserialization but again i faced error at deserialization time. is there any solution to this ?
BR,
镭
推荐答案
我将创建一个新的序列化
对象,并添加意向的部分
你有兴趣,也就是行动,捆绑参数等。
I would create a new Serializable
object and add the parts of the Intent
that you are interested in, ie, action, bundle parameters, etc.
的意图
对象本身并不序列化
。
另一种方法是写一个存储在另一个序列化
对象类型,然后将值自己的包裹
实行序列化对象到服务器。你可以写一个意图
到包裹
使用 Intent.writeToParcel()
API
Another approach may be to write your own Parcel
implemenation that stores the values in another Serializable
object type and then serialize that Object to server. You can write an Intent
to a Parcel
using the Intent.writeToParcel()
api.
这篇关于序列化的Android意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!