latimerius wrote:

> Mark Murphy wrote:
>>
>> That is a documentation flaw. Android does not "destroy this instance
>> of the activity to save space", except by terminating the entire
>> process. isFinishing() will distinguish multiple reasons for onPause()
>> and onStop() being called (e.g., BACK will cause isFinishing() to
>> return true, HOME will cause isFinishing() to return false).
>
>
> That's strange.  What I see in an Activity that initialises some static 
> data in its onCreate() is that occasionally, the statics are 
> initialised already when onCreate() starts to execute.
>
> I thought this was a sign that a previous instance of the Activity (the 
> one that initialised the static data presumably) had been destroyed but the 
> process was not.  Is there a better explanation?
>

Instances do not initialize static members in Java. The static members are 
initialized as part of 
class initialization.

Instances can set static values if they're mutable, but that's not 
initialization.

I don't know about processes being destroyed or not, but the creation or 
collection of instances in 
a JVM is not related to the initialization or destruction of static members.

If the class is not unloaded, its static variables will continue to hold 
whatever values they had at the 
point of latest assignment, or their initialized values if there hasn't 
been an assignment.

If a class is unloaded and reloaded, or loaded under a different 
classloader for the first time, it will be 
(re-)initialized upon the first subsequent class-initialization event (such 
as a reference to a member or 
creation of an instance).

So your question reduces to finding out under what circumstances the class 
under investigation 
is unloaded, loaded and initialized.

Based on the answers upthread, and I'm in no position to dispute them, the 
class does not unload
every time the Activity stops. But it sometimes does.

There is only one "better" explanation, and that's a correct one. Yours was 
not. Distinguish between 
initialization and assignment.

-- 
Lew

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to