I am having a really hard time grokking the Activity life cycle
concept.  The main issue is with onStop() and onDestory() not being
guaranteed to be called before the process is killed.  I though I had
it figured out when I saw that the system calls onSaveInstanceState()
when it's shutting down the activity to claim some memory.  Thing is
that the docs says onSaveInstanceState() will be called before
onPause() but how does the system know at this point whether the
activity will be killed by the system or the user?

Here is a use case:

1) My activity starts up and is running.
2) At some point I want to show a web page so I use an Intent to start
an activity.
3) The web browser covers my app/activity so I would expect onPause()
to be called followed by onStop().

At this point it's my understanding that all bets are off and I can be
killed at any point without be called.

4) Since the system has enough memory onSaveInstance() doesn't get
called.
5) The user presses home and decides to open some app which requires a
lot of memory.
6) System wants more memory and decides to kill my app but I am
already stopped (onPause() has been called).  What happens here?

I am finding this a really serious problem since onPause() pretty much
needs to be treated as onDestory() as far as I can tell. If my app has
to be able to survive being killed without onStop() and onDestory()
being called, why bother having them?

-- 
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