I was pretty sure that I understood the Android lifecycle and how
applications/processes might be start/stopped/removed and how that
effects whether variables remain initialized.  I am, however, seeing
some funky behavior in my app such that I am afraid I have missed
something.

I use a singleton pattern for some of my objects.  That is, the
constructor is private and you call a static getInstance() method to
construct the object.  The static instance variable is, of course,
initialized to NULL which is the trigger for getInstance to know whether
the object needs to be constructed.

I have learned that any code that calls getInstance() cannot assume that
the object it has constructed continues to live in memory since my
application might have been killed by Android.  So throughout my code I
always call getInstance() to ensure that I have a valid object.  Am I
correct in assuming that had I been killed that getInstance() will
create a new object?  In other words, will my static instance variable
have been reset to NULL or might my factory method give me back a stale
pointer?

...Jake


-- 
Jake Colman -- Android Tinkerer

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

Reply via email to