Confusion easily comes from thinking about the home screen and the home key as being more special than they are.
The home screen, to a large degree, is just another application. When it comes to the foreground, the usual rules with onPause / onStop apply to the current application. As for not being able to override the Home key - there are all sorts of intents that only the system can broadcast. I don't remember anyone asking how to prevent the user from pressing the power key to unlock the phone :) -- Kostya 2011/6/8 Robert Green <[email protected]> > Think of home like alt-tab in windows. You never need to capture it. > You just need to handle onPause()/onStop() in a way that makes sense > for the user temporarily leaving your app. You'll get onFinish() when > your app is to be actually destroyed. If you have a need to actually > kill off the whole thing when home is pressed, call finish() in > onPause()/onStop() and you shall receive the touch of the droid > reaper, making for a clean start next time the user tries to enter the > activity. > > On Jun 8, 10:31 am, Indicator Veritatis <[email protected]> wrote: > > Your blog post IS the best explanation I have seen to date of what the > > Home key really means. I thought it was particularly interesting that > > it emphasized something I have been dimly aware of but keep > > forgetting: unlike the Back key, pressing Home does NOT cause finish() > > to be called. I assume from your description that it triggers only one > > lifecycle callback, onPause(). It doesn't even itself trigger > > onStop(), which may or may not follow. > > > > But shouldn't it trigger onStop() too? After all, the application is > > no longer visible. And what about the Activity Stack? Doesn't pressing > > Home put the least recently used Activity on that stack? > > > > In fact, when I put Log.d statements in my main Activity for both > > onPause() and onStop(), I see both get called when I press the Home > > key. > > > > On Jun 8, 5:13 am, Mark Murphy <[email protected]> wrote: > > > > > > > > > > > > > > > > > On Wed, Jun 8, 2011 at 7:20 AM, Mark Murphy <[email protected]> > wrote: > > > > On Wed, Jun 8, 2011 at 2:31 AM, Droid <[email protected]> wrote: > > > >> I need to know when the home button is pressed too (otherwise my app > > > >> returns to visibility again and again for ever). > > > > > > Then fix your bug. > > > > > >> (Please don't tell me I need to design my app > > > >> 'properly', I have been Android dev for over a year now) > > > > > > Tough. Design your app properly. > > > > > I just wrote up a blog post about why you should not care about the > > > HOME button and how better to solve this "problem": > > > > >http://commonsware.com/blog/2011/06/08/please-ignore-home-button.html > > > > > -- > > > Mark Murphy (a Commons Guy)http://commonsware.com| > http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > > > Android 3.0 Programming Books:http://commonsware.com/books > > -- > 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 > -- 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

