According to this question in OS you need to serialize objects because they are passed to a class called ActivityManagerNative
which is in a separate process from the other applications.
When two distinct processes want to communicate memory is not shared and therefore it is not possible to move the same object from one to another.
But the answer does not go into the merit of why communication was designed to work that way.
The most likely explanation is that Android's% com_communication communication engine is designed to work both between components ( Intent
, Activities
, etc.) of the same process (application) and between components of different processes (from% application_com% A to% application_com% B, for example).
That is, serialization is required to allow data transfer via Services
(Interprocess communication).
Between two Activity
of the same process it is possible to communicate without serializing the object, just do not use the Activity
mechanism and instead use a shared resource (a static global object or inherited by both IPC
, or even a Singleton ).