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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to