Java Code Examples for android.view.KeyEvent#FLAG_LONG_PRESS
The following examples show how to use
android.view.KeyEvent#FLAG_LONG_PRESS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaSessionService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void handleVoiceKeyEventLocked(String packageName, int pid, int uid, boolean asSystemService, KeyEvent keyEvent, boolean needWakeLock) { int action = keyEvent.getAction(); boolean isLongPress = (keyEvent.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0; if (action == KeyEvent.ACTION_DOWN) { if (keyEvent.getRepeatCount() == 0) { mVoiceButtonDown = true; mVoiceButtonHandled = false; } else if (mVoiceButtonDown && !mVoiceButtonHandled && isLongPress) { mVoiceButtonHandled = true; startVoiceInput(needWakeLock); } } else if (action == KeyEvent.ACTION_UP) { if (mVoiceButtonDown) { mVoiceButtonDown = false; if (!mVoiceButtonHandled && !keyEvent.isCanceled()) { // Resend the down then send this event through KeyEvent downEvent = KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_DOWN); dispatchMediaKeyEventLocked(packageName, pid, uid, asSystemService, downEvent, needWakeLock); dispatchMediaKeyEventLocked(packageName, pid, uid, asSystemService, keyEvent, needWakeLock); } } } }
Example 2
Source File: ExFilePickerActivity.java From ExFilePicker with MIT License | 6 votes |
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_UP) { if (mIsMultiChoiceModeEnabled) { setMultiChoiceModeEnabled(false); setupOkButtonVisibility(); } else { if (isTopDirectory(mCurrentDirectory)) { finish(); } else { readUpDirectory(); } } } else if (event.getAction() == KeyEvent.ACTION_DOWN && (event.getFlags() & KeyEvent.FLAG_LONG_PRESS) == KeyEvent.FLAG_LONG_PRESS) { finish(); } return true; } return super.dispatchKeyEvent(event); }
Example 3
Source File: KeyButtonView.java From GravityBox with Apache License 2.0 | 5 votes |
void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) { try { final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0; if (applyDefaultFlags) { flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY; } final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_KEYBOARD); final Object inputManager = XposedHelpers.callStaticMethod(InputManager.class, "getInstance"); XposedHelpers.callMethod(inputManager, "injectInputEvent", ev, 0); } catch (Throwable t) { XposedBridge.log(t); } }
Example 4
Source File: BtnsNavbar.java From XposedNavigationBar with GNU General Public License v3.0 | 4 votes |
@Override protected void longHome() { KeyEvent keyEvent = new KeyEvent(KeyEvent.FLAG_LONG_PRESS, KeyEvent.KEYCODE_HOME); mInst.sendKeySync(keyEvent); }