序列化的Andr​​oid意图 [英] Serialization Android intent

查看:146
本文介绍了序列化的Andr​​oid意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现应用程序序列化的Andr​​oid意图,通过套接字从客户发送到服务器和反序列化的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.

这篇关于序列化的Andr​​oid意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆