Domanda

Is parcelable data persistent? I have some variables that I destroy in android lifecycle functions such as onDestroy() , but what about things written to parcelable?

Ultimately I would want to pass elements of my parcelable objects via intents, will they still be available after garbage collection (either java or dalvik's)?

thank you

È stato utile?

Soluzione

The short answer is: yes. Parcelable data is persistent.

When you make a Parcel out of an object, you are basically creating a serialized version of the at object. Once you have the serialized version, the object itself can be garbage-collected and you will still have the Parcel (assuming that you have kept a handle on that, or if you have sent it via Intent then the OS has a handle on it).

At another time you can instantiate a new object from the Parcel and you will end up with a copy of the original object, regardless of whether the original object has been garbage-collected or not.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top