Like the combination of Power button and Volume down button - takes a screenshot of the phone... similarly I am trying to access volume up and power button long pressed keys in my app and give a shortcut. Is this possible?
I know how to get the access of both buttons individually but not combined at the same time.
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_POWER){
Log.w("LongPress", "power LONG PRESS");
}
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP){
Log.w("LongPress", "Volume Up LONG PRESS");
}
return super.onKeyLongPress(keyCode, event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP){
event.startTracking();
return true;
}
return super.onKeyDown(keyCode, event);
}
How to get the combination done here '&&' doesn't work?