tags:

views:

229

answers:

1

Does anyone know how to handle Android HTC device Red (power) button programatically to stop my operation. I want to stop running some of my operation when user presses REd button when user is in my screen. I know for other buttons like Back button i could use "keyCode == KeyEvent.KEYCODE_BACK" event. But what is for Power(End) Red button? I'm not getting any keycode events for Red button when i'm in my application.

thanks.

+1  A: 

AFAIK, you cannot override the END_CALL key event in an Activity or View.

CommonsWare
Ok. Do we know when screen is going off mode? Do we get any notification or find whether screen is off or not?
There is a SCREEN_OFF broadcast Intent you can listen for.
CommonsWare