Android: Detecting user tampering with phone

570 views Asked by At

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?

1

There are 1 answers

1
ashish.n On

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;
}