Why does this key only get dispatched on a long press. Im trying to have it so that normal press of the power button mutes the currently playing audio in the Ringer stream. It only works on long press, normal press turns the screen off. I need it to work on normal press.
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_POWER:
if (ringer == null)
return super.dispatchKeyEvent(event);
if (!mute)
if (ringer.isRinging())
ringer.stopRing();
else if (!ringer.isRinging())
ringer.ring();
mute = !mute;
return true;
}
return super.dispatchKeyEvent(event);
}