I need to know when the user will press the power key continuously 2 or 3 times. But in the case the user is out of the application lets say on the home screen or even using any other application.
I getting the listener event of the power key on the activity but not on the service.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(KeyEvent.KEYCODE_POWER == event.getKeyCode()){
Log.e("POWER", "pow");
return true;//If event is handled, falseif
}
return super.onKeyDown(keyCode, event);
}
How can i know if the user has pressed the power button outside the activity?