List of usage examples for android.view KeyEvent FLAG_CANCELED_LONG_PRESS
int FLAG_CANCELED_LONG_PRESS
To view the source code for android.view KeyEvent FLAG_CANCELED_LONG_PRESS.
Click Source Link
From source file:io.github.hidroh.materialistic.KeyDelegate.java
/** * Calls from {@link Activity#onKeyUp(int, KeyEvent)} to delegate * @param keyCode event key code/* w ww.j ava2s .co m*/ * @param event key event * @return true if is intercepted as navigation, false otherwise */ public boolean onKeyUp(int keyCode, KeyEvent event) { if (!mEnabled) { return false; } boolean notLongPress = (event.getFlags() & KeyEvent.FLAG_CANCELED_LONG_PRESS) == 0; if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && notLongPress) { shortPress(DIRECTION_UP); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && notLongPress) { shortPress(DIRECTION_DOWN); return true; } return false; }