We were wondering if when using Bundle
with serializable or parcelable objects, when does the marshalling actually happen? As soon as you put it in the bundle? Since bundles are mostly used to simply pass around data between two screens (we're not even talking about IPC here!), there doesn't seem to be much point in marshalling an object, since it stays in memory all the time, no?
Are we right in assuming that marshalling (be it Java serializing or Android parcelling) only happens if
- the data must be passed to another process, e.g. during RMI, or
- the component (activity or service) gets destroyed and instance state must be written to disk?
I've seen Android framework engineers (I believe it was Dianne Hackborn) say that one should use Parcelable
instead of Serializable
because the former is much faster. How much faster? And will this even make a difference if the object isn't marshalled most of the time anyway (assuming our assumptions about this were right)?