On the other hand, having since the previous post re-read http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html, another example of required reading, I see that I overstated my case. Almost all applications, if following those guidelines, will cause the system to call finish() on the Activity, removing it from the Activity stack.
Interestingly enough, not every exception to this rule is a violation of the guidelines: the guidelines themselves point out that a web browser will handle the Back key itself to maintain a "back stack" for each window, calling finish() only when those back stacks are all empty. Of course, it is finish() that causes onPause()... on Destroy() to be called; or just onDestroy() if the others have already been called. That said, I suspect not following those guidelines is more common than Google would like, because I just hit Back several times on the Settings application, causing it to leave the foreground, yet it is still listed as being in memory, just no longer foreground. On Jul 3, 4:50 pm, Indicator Veritatis <[email protected]> wrote: > This is certainly wrong. Pressing the Back key does NOT cause > onDestroy() to be called. It causes onPause() to be called. I have run > this in the emulator too many times myself to believe that it does. > The application goes into the background, but it remains in memory, on > the activity stack. Only much later, if at all, is onDestroy() called. > Since most applications do not provide an 'Exit' button/key, and many > users do not use a Task Killer, onDestroy() might not be called until > power-down (or the next configuration change). > > On Jul 2, 12:55 pm, Mark Murphy <[email protected]> wrote: > > > On Fri, Jul 2, 2010 at 3:38 PM, david2 <[email protected]> wrote: > > >> onPause() is called whenever the activity loses the foreground from an > > >> input standpoint. > > > >> onStop() is also called, if the activity is no longer visible on the > > >> screen. > > > >> onDestroy() is also called, if the activity instance is going away for > > >> good. > > > >> Hence, BACK calls onPause(), onStop(), and onDestroy(). HOME calls > > >> onPause() and onStop(). > > > > Not true. Back does not call onDestroy. > > > Yes, it does. > > > > On destroy is called when the > > > system decides the application is going away. > > > Such as when the user presses the BACK button. > > > > This does not normally > > > occur on a back button or home button. > > > Yes, it does normally occur on a BACK button. > > > > Processes stay around until > > > memory is needed elsewhere. > > > Which has little to do with onDestroy() of individual components > > within that process. > > > > And even then, documentation states that > > > onDestroy may never get called even when the application is killed. > > > Correct. > > > > In general BACK doesn't do anything additional vs. HOME. > > > Yes, it does. It causes the activity to be destroyed. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > Android Training...At Your Office:http://commonsware.com/training > > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

