0

I'd like to detect when a user presses any hardware button on a sleeping android phone (or at least the home and the power button).

Until now I have used a BroadcastReceiver for the ACTION_SCREEN_ON event, which works great but it is also raised when e.g. you get a message, a phone call or when an alarm starts.

ACTION_USER_PRESENT is also no option because this is only raised when the user really is present an knows the unlock code, so he isn't tampering with the phone.

Is there a way to handle that?

DominicM
  • 2,186
  • 5
  • 24
  • 42

1 Answers1

0

no its not possible but this can be used for other purpose

public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) 
    {



    }
    return true;
}
ashish.n
  • 1,234
  • 14
  • 30