Christian
Christian

Reputation: 26427

Android bundles passing Pointer or copies of objects

If I attach an object to a bundle and store the bundle in an intent and start another activity, does that activity work on a copy of the original object or does it use the same object but just passes along a pointer?

Upvotes: 4

Views: 1585

Answers (1)

RoflcoptrException
RoflcoptrException

Reputation: 52249

In Java there is no such thing as pointers. You can either pass and object by value or by reference.

CommonsWare listed the possibilities the following way:

  1. Use remote services and AIDL to implement a remote procedure call, effectively giving you "pass by reference" between apps
  2. Use Parceable and Intent extras, effectively giving you "pass by value" between apps

So you pass your objects by value.

Upvotes: 4

Related Questions