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:com.example.innf.newchangtu.Map.view.activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { sendSMSTime = System.currentTimeMillis();/*?*/ if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawerLayout.isDrawerOpen(GravityCompat.START)) { drawerLayout.closeDrawer(GravityCompat.START); } else {//from w w w . j av a 2 s.c o m AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.setTitle(R.string.app_name).setIcon(R.mipmap.ic_launcher) .setMessage("?") .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); System.exit(0); } }).setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).show(); } return true; } else if (keyCode == KeyEvent.KEYCODE_POWER && event.getAction() == KeyEvent.ACTION_DOWN) { if ((System.currentTimeMillis() - sendSMSTime) < 2000) { powerButtonClickTimes++; if (powerButtonClickTimes == 4) { Log.d(TAG, powerButtonClickTimes + ""); showToast("???"); } } else { powerButtonClickTimes = 0; } } return super.onKeyDown(keyCode, event); }
From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { LogUtil.d(TAG, "keycode back , chatfooter mode: " + mChattingFooter.getMode()); if (!mChattingFooter.isButtomPanelNotVisibility()) { hideBottom();/*from w ww . j ava2 s .c om*/ return true; } setIsFinish(true); } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (event.getAction() == KeyEvent.ACTION_DOWN) { mHandlerDelChar = !(mChattingFooter.getCharAtCursor() != (char) (8197)); } if (event.getAction() == KeyEvent.ACTION_UP && mHandlerDelChar) { mHandlerDelChar = false; CCPChattingFooter2 footer = this.mChattingFooter; int selectionStart = footer.getSelectionStart(); String text = footer.getLastText().substring(0, selectionStart); int atIndex = text.lastIndexOf('@'); if (atIndex < text.length() && atIndex >= 0) { delAtSomeBody(text.substring(atIndex, selectionStart)); String subStartText = text.substring(0, atIndex); String subSecondText = footer.getLastText().substring(selectionStart); StringBuilder sb = new StringBuilder(); sb.append(subStartText).append(subSecondText); footer.setLastText(sb.toString()); footer.mEditText.setSelection(atIndex); } } } return super.onKeyDown(keyCode, event); }
From source file:android.support.v7.app.AppCompatDelegateImplV7.java
boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_MENU: onKeyUpPanel(Window.FEATURE_OPTIONS_PANEL, event); return true; case KeyEvent.KEYCODE_BACK: PanelFeatureState st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false); if (st != null && st.isOpen) { closePanel(st, true);/*from ww w . ja va 2 s. c o m*/ return true; } if (onBackPressed()) { return true; } break; } return false; }
From source file:com.freerdp.freerdpcore.presentation.SessionActivity.java
@Override public boolean onKeyDown(int keycode, KeyEvent event) { if (keycode == KeyEvent.KEYCODE_BACK && rladvertising.getVisibility() == View.VISIBLE) { try {/*from ww w .j av a 2 s .c o m*/ connectCancelledByUser = true; rladvertising.stopPlay(); rladvertising.getLock().notifyAll(); LibFreeRDP.cancelConnection(session.getInstance()); } catch (Exception e) { } finish(); return false; } if (event.getRepeatCount() == 0 && keycode == KeyEvent.KEYCODE_BACK) { event.startTracking(); return true; } return keyboardMapper.processAndroidKeyEvent(event); }
From source file:com.jinrustar.sky.main.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { // if(search_layout.getVisibility()==View.VISIBLE){ // search_layout.setVisibility(View.GONE); // scan.setEnabled(true); // return true; // } long secondTime = System.currentTimeMillis(); if (secondTime - firstTime > 2000) { Toast.makeText(this, R.string.another_click_to_quit, Toast.LENGTH_SHORT).show(); firstTime = secondTime;//from w ww .j a va2 s. c om return true; } else { finish(); System.exit(0); return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.ichi2.anki.Info.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) { mWebView.goBack();// w w w . j av a 2 s . c o m } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) { Intent result = new Intent(); result.putExtra(TYPE_ANIMATION_RIGHT, true); switch (mUpgradeStage) { case UPGRADE_SCREEN_BASIC2: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_MORE_OPTIONS: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_WEB_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_PC_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_MANUAL_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_AUTO_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE); break; } setResult(RESULT_OK, result); finishWithAnimation(false); } else { Timber.i("onBackPressed()"); setResult(RESULT_CANCELED); finishWithAnimation(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH) { // Send the search key to the leftmost fragment Fragment f = mFragmentManager.findFragmentById(R.id.left_container); if (((FamiliarFragment) f).onInterceptSearchKey() == false) { return super.onKeyDown(keyCode, event); } else {/*from w w w.ja va 2 s .co m*/ return true; } } else if (keyCode == KeyEvent.KEYCODE_BACK) { // If we're not at the root of a hierarchy, the back button should do as it pleases if (getSupportFragmentManager().getBackStackEntryCount() > 0 || !this.isTaskRoot()) { return super.onKeyDown(keyCode, event); } // Else if were at the root, and the SlidingMenu is closed, it should open the menu else if (!this.getSlidingMenu().isMenuShowing()) { this.getSlidingMenu().showMenu(); return true; } // If the SlidingMenu is open, it should close the app else { return super.onKeyDown(keyCode, event); } } return super.onKeyDown(keyCode, event); }
From source file:com.ichi2.anki2.Info.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) { mWebView.goBack();/*from w w w . j a v a 2s. c om*/ } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) { Intent result = new Intent(); result.putExtra(TYPE_ANIMATION_RIGHT, true); switch (mUpgradeStage) { case UPGRADE_SCREEN_BASIC2: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_MORE_OPTIONS: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_WEB_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_PC_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_MANUAL_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_AUTO_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE); break; } setResult(RESULT_OK, result); finishWithAnimation(false); } else { Log.i(AnkiDroidApp.TAG, "Info - onBackPressed()"); setResult(RESULT_CANCELED); finishWithAnimation(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.hichinaschool.flashcards.anki.Info.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) { mWebView.goBack();/*from w w w . j av a2s. c o m*/ } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) { Intent result = new Intent(); result.putExtra(TYPE_ANIMATION_RIGHT, true); switch (mUpgradeStage) { case UPGRADE_SCREEN_BASIC2: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_MORE_OPTIONS: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); break; case UPGRADE_SCREEN_WEB_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_PC_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_MANUAL_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); break; case UPGRADE_SCREEN_AUTO_UPGRADE: result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE); break; } setResult(RESULT_OK, result); finishWithAnimation(false); } else { // Log.i(AnkiDroidApp.TAG, "Info - onBackPressed()"); setResult(RESULT_CANCELED); finishWithAnimation(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.borax12.materialdaterangepicker.time.TimePickerDialog.java
/** * For keyboard mode, processes key events. * @param keyCode the pressed key.//ww w .j a v a 2s . c o m * @return true if the key was successfully processed, false otherwise. */ private boolean processKeyUp(int keyCode) { if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) { if (isCancelable()) dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (mInKbMode) { if (isTypedTimeFullyLegal()) { finishKbMode(true); } return true; } } else if (keyCode == KeyEvent.KEYCODE_ENTER) { if (mInKbMode) { if (!isTypedTimeFullyLegal()) { return true; } finishKbMode(false); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes(), mTimePickerEnd.getHours(), mTimePickerEnd.getMinutes()); } dismiss(); return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { if (mInKbMode) { if (!mTypedTimes.isEmpty()) { int deleted = deleteLastTypedKey(); String deletedKeyStr; if (deleted == getAmOrPmKeyCode(AM)) { deletedKeyStr = mAmText; } else if (deleted == getAmOrPmKeyCode(PM)) { deletedKeyStr = mPmText; } else { deletedKeyStr = String.format("%d", getValFromKeyCode(deleted)); } if (tabHost.getCurrentTab() == 0) { Utils.tryAccessibilityAnnounce(mTimePicker, String.format(mDeletedKeyFormat, deletedKeyStr)); } else { Utils.tryAccessibilityAnnounce(mTimePickerEnd, String.format(mDeletedKeyFormat, deletedKeyStr)); } updateDisplay(true); } } } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9 || (!mIs24HourMode && (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) { if (!mInKbMode) { if (mTimePicker == null) { // Something's wrong, because time picker should definitely not be null. Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null."); return true; } mTypedTimes.clear(); tryStartingKbMode(keyCode); return true; } // We're already in keyboard mode. if (addKeyIfLegal(keyCode)) { updateDisplay(false); } return true; } return false; }