I want to pass objects between Activities and Services on Android. The straight forward way to do this is to make your objects implement Serializabl
e or 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.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.
What you think?
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.
I believe both the methods have its own importance.
But still there is one more option, which you can use. You can make your object static and access it from other Activity. if object is not a lot bulky, then this is also good choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With