2
I would like to trigger an event just by pressing the 2x volume button quickly.
I have the following code, but it fires by pressing the button only once. How to make it fire only if pressed 2 times at a certain speed?
Follows the code:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) {
toDoUp();
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
toDoDown();
}
return true;
default:
return super.dispatchKeyEvent(event);
}
}
This is possible but the first click will be passed to the system. It serves as such?
– ramaral
That is the volume indicator will open. If it fits like this I give an answer.
– ramaral