When passing a Bundle
object from Activity
to another Activity
, Android framework will parcel and unparcel your object, the unparcel process will create a new object;
When passing a Bundle
object through Message
, Message.setData()
just set the object, without doing parcel, so you are accessing the same object.
you can check Bundle
source, your data is stored either in a Map
or Parcel
:
// Invariant - exactly one of mMap / mParcelledData will be null
// (except inside a call to unparcel)
/* package */ Map<String, Object> mMap = null;
/*
* If mParcelledData is non-null, then mMap will be null and the
* data are stored as a Parcel containing a Bundle. When the data
* are unparcelled, mParcelledData willbe set to null.
*/
/* package */ Parcel mParcelledData = null;
the Bundle.unparcel()
method recreates your objects from Parcel
.