本文介绍了序列化对象在Android里面发送意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过Android上的活动和服务的对象。在直接的方式做到这一点是让你的对象实施 Serializabl e或 Parcelable

I want to pass objects between Activities and Services on Android. The straight forward way to do this is to make your objects implement Serializable or Parcelable.


  • 序列化这是比较糟糕的表现。

  • Parcelable ,另一方面要求我去实现和维护自己的序列化,即永远要记住在未来的更新。

  • Serializable it's relatively bad performance.
  • Parcelable on the other hand requires me to implement and maintain the serialization myself i.e. always to remember to update it in the future.

我想使用杰克逊JSON序列完成这个任务。
它的速度更快比Java内置的序列化和不需要我编写和维护serializtion code。

I was thinking about using Jackson Json serializer for this task.It's faster than Java built in serialization and does not require me write and maintain serializtion code.

什么你觉得呢?

推荐答案

如果性能很重要,那么你真的应该去Parcelable。 JSON将相对缓慢,因为它比Parcelable它是专门在Android中实现对进程间通信打包数据时提高性能效率较低。

If performance is important, then you really should go with Parcelable. JSON will be relatively slow because it is less efficient than Parcelable which was specifically implemented in Android for improving performance when packaging data for Inter-Process Communication.

这篇关于序列化对象在Android里面发送意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 03:57