I have a bug in my code that made me think I don\'t fully understand the Android Lifecycle. Yes, I have read all the docs and looked at the diagrams, but they seem to talk only
onDestroy
is an instance method and any memory it releases (or allows the garbage collector to release) will be of the corresponding instance. Activities are not singleton; there can be more than one instance of an Activity.
Static variables are class variables and are accesible to all instances of that class. They are initialized when the class is loaded, not when each instance of the class is created.
Please see Understanding Instance and Class members for more info. An excerpt:
Sometimes, you want to have variables that are common to all objects. This is accomplished with the static modifier. Fields that have the static modifier in their declaration are called static fields or class variables. They are associated with the class, rather than with any object. Every instance of the class shares a class variable, which is in one fixed location in memory. Any object can change the value of a class variable, but class variables can also be manipulated without creating an instance of the class.