List of usage examples for android.view KeyEvent KEYCODE_BACK
int KEYCODE_BACK
To view the source code for android.view KeyEvent KEYCODE_BACK.
Click Source Link
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { final View visibleDrawer = findVisibleDrawer(); if (visibleDrawer != null && getDrawerLockMode(visibleDrawer) == LOCK_MODE_UNLOCKED) { closeDrawers();//from ww w .j av a 2s . c o m } return visibleDrawer != null; } return super.onKeyUp(keyCode, event); }
From source file:com.hijacker.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else if (mFragmentManager.getBackStackEntryCount() > 1) { mFragmentManager.popBackStackImmediate(); } else {/* w w w. ja v a 2s. c om*/ new ExitDialog().show(mFragmentManager, "ExitDialog"); } return true; } return super.onKeyDown(keyCode, event); }
From source file:android.support.v7.widget.AbstractXpListPopupWindow.java
/** * Filter pre-IME key events. By forwarding {@link View#onKeyPreIme(int, KeyEvent)} * events to this function, views using ListPopupWindow can have it dismiss the popup * when the back key is pressed./* w ww .j a v a 2s . com*/ * * @param keyCode keyCode param passed to the host view's onKeyPreIme * @param event event param passed to the host view's onKeyPreIme * @return true if the event was handled, false if it was ignored. * @see #setModal(boolean) */ public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && isShowing()) { // special case for the back key, we do not even try to send it // to the drop down list but instead, consume it immediately final View anchorView = mDropDownAnchorView; if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState(); if (state != null) { state.startTracking(event, this); } return true; } else if (event.getAction() == KeyEvent.ACTION_UP) { KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState(); if (state != null) { state.handleUpEvent(event); } if (event.isTracking() && !event.isCanceled()) { dismiss(); return true; } } } return false; }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // // w w w . j av a 2s .co m if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { if ((System.currentTimeMillis() - exitTime) > 2000) // System.currentTimeMillis()2000 { Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show(); exitTime = System.currentTimeMillis(); } else { if (mChatService != null) mChatService.stop(); finish(); System.exit(0); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.example.carsharing.CommuteActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent returnp = new Intent(CommuteActivity.this, PersonalCenterActivity.class); returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(returnp);// w w w .j a v a 2 s . c om return false; } else { return super.onKeyDown(keyCode, event); } }
From source file:org.zirco.ui.activities.MainActivity.java
@Override public boolean onKeyLongPress(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: this.moveTaskToBack(true); return true; default:/*from w w w. j a va 2s . c o m*/ return super.onKeyLongPress(keyCode, event); } }
From source file:com.android.tv.MainActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (SystemProperties.LOG_KEYEVENT.getValue()) Log.d(TAG, "dispatchKeyEvent(" + event + ")"); // If an activity is closed on a back key down event, back key down events with none zero // repeat count or a back key up event can be happened without the first back key down // event which should be ignored in this activity. if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { mBackKeyPressed = true;//from ww w. java2 s . c o m } if (!mBackKeyPressed) { return true; } if (event.getAction() == KeyEvent.ACTION_UP) { mBackKeyPressed = false; } } // When side panel is closing, it has the focus. // Keep the focus, but just don't deliver the key events. if ((mOverlayRootView.hasFocusable() && !mOverlayManager.getSideFragmentManager().isHiding()) || mOverlayManager.getSideFragmentManager().isActive()) { return super.dispatchKeyEvent(event); } if (BLACKLIST_KEYCODE_TO_TIS.contains(event.getKeyCode()) || KeyEvent.isGamepadButton(event.getKeyCode())) { // If the event is in blacklisted or gamepad key, do not pass it to session. // Gamepad keys are blacklisted to support TV UIs and here's the detail. // If there's a TIS granted RECEIVE_INPUT_EVENT, TIF sends key events to TIS // and return immediately saying that the event is handled. // In this case, fallback key will be injected but with FLAG_CANCELED // while gamepads support DPAD_CENTER and BACK by fallback. // Since we don't expect that TIS want to handle gamepad buttons now, // blacklist gamepad buttons and wait for next fallback keys. // TODO) Need to consider other fallback keys (e.g. ESCAPE) return super.dispatchKeyEvent(event); } return dispatchKeyEventToSession(event) || super.dispatchKeyEvent(event); }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (volumeButtons && (keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { return true; } else if (!vbListenerPause && keyCode == KeyEvent.KEYCODE_BACK) { screen = 1;//w w w .j ava 2s . c om if (shakeDelete) { mShaker.pause(); } vbListenerPause = true; return true; } else { return super.onKeyUp(keyCode, event); } }
From source file:co.taqat.call.LinphoneActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (currentFragment == FragmentsAvailable.DIALER || currentFragment == FragmentsAvailable.CONTACTS_LIST || currentFragment == FragmentsAvailable.HISTORY_LIST || currentFragment == FragmentsAvailable.CHAT_LIST) { boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled(); if (!isBackgroundModeActive) { stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); finish();/* w ww.j a v a 2 s. c o m*/ } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) { return true; } } } return super.onKeyDown(keyCode, event); }