Task: In the first activity of Activity1, we create an instance of the VeryFatClass class:
VeryFatClass obj = new VeryFatClass ();
We carry out the necessary actions with him, and we want to transfer this particular object to Activity2 .
Problem: The fields of the VeryFatClass class are for the most part other objects in which fields are also objects (and in some of them fields are also objects).
How to organize control over the VeryFatClass object from more than 2 activities? my current solution is, I use a static field and a singleton pattern, but it seems to me that it is not quite right, because I have to hope that the cleaner will not demolish the instance I created in the first activity. Is there a way to protect yourself from this? I read about Parcelable , but as I understand it, I would have to do every field in which there is an object to do as Parcelable ?
ParcelableYes, you need to expand the object into primitive types. - pavlofffActivity. TheParcelablemay not work on Android Nougat due to the transaction size limit ( developer.android.com/reference/android/os/… ) + at any time the system can kill the application process and the object is lost. - EgorD