Application's can receive the power key, since we don't want them to be able to keep the user from turning off their device. :}
ACTION_SCREEN_OFF will always be sent, though note it can only be received by use of registerReceiver() -- it will not be sent to receivers declared in the manifest. On Sun, Aug 8, 2010 at 6:35 PM, Mark Murphy <[email protected]> wrote: > On Sun, Aug 8, 2010 at 9:16 PM, KwangWon <[email protected]> wrote: > > I would like to write an application which shutdown (finish()) itself > > when the sleep button is pressed. Any hint? Thanks, > > If by "sleep button" you mean "power button", you can try watching > for the KEYCODE_POWER KeyEvent. I haven't tried this, but it's in the > documentation. > > You can also watch for the ACTION_SCREEN_OFF broadcast, but that will > be invoked at other times as well (e.g., user doesn't touch the device > for a while, so it goes to sleep). > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > _The Busy Coder's Guide to Android Development_ Version 3.1 Available! > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer 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

