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.cognizant.trumobi.PersonaLauncher.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // PersonaLog.e(LOG_TAG, "keyCode" + keyCode); //System.out.println("==========OnKeyDown ===========" + keyCode); //System.out.println("===========KeyEvent" + event.getAction()); boolean handled = super.onKeyDown(keyCode, event); if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { return true; }// ww w . ja v a2s . com if (112 == keyCode) /* 112 represents F2 key; */ { /* Invoke Application PersonaDrawer screen in case F2 is selected */ fireHomeBinding(BIND_APPS, 0); } else if (!handled && acceptFilter() && keyCode != KeyEvent.KEYCODE_ENTER) { /* * boolean gotKey = * TextKeyListener.getInstance().onKeyDown(mWorkspace, * mDefaultKeySsb, keyCode, event); * * if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > * 0) { // something usable has been typed - start a search // the * typed text will be retrieved and cleared by // showSearchDialog() * // If there are multiple keystrokes before the search dialog * takes focus, // onSearchRequested() will be called for every * keystroke, // but it is idempotent, so it's fine. return * onSearchRequested(); } */ return true; } if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) { return true; } if (keyCode == KeyEvent.KEYCODE_BACK) { onBackPressed(); } return handled; }
From source file:com.example.android.bluepayandroidsdk.MainActivity.java
private void showYesNoDialog() { hideSwipeTopDialog();/* w ww . ja va2 s . c o m*/ try { if (dlgYESNOTopShow == null) dlgYESNOTopShow = new UniMagTopDialogYESNO(this); Window win = dlgYESNOTopShow.getWindow(); win.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); dlgYESNOTopShow.setTitle("Warning"); dlgYESNOTopShow.setContentView(R.layout.dlgtopview2bnt); TextView myTV = (TextView) dlgYESNOTopShow.findViewById(R.id.TView_Info); myTV.setTextColor(0xFF0FF000); Button myBtnYES = (Button) dlgYESNOTopShow.findViewById(R.id.btnYes); Button myBtnNO = (Button) dlgYESNOTopShow.findViewById(R.id.btnNo); // myTV.setText("Warrning, Now will Update Firmware if you press 'YES' to update, or 'No' to cancel"); myTV.setText( "Upgrading the firmware might cause the device to not work properly. \nAre you sure you want to continue? "); myBtnYES.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { updateFirmware_exTools(); dlgYESNOTopShow.dismiss(); } }); myBtnNO.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { dlgYESNOTopShow.dismiss(); } }); dlgYESNOTopShow.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { return false; } return true; } }); dlgYESNOTopShow.show(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.example.carsharing.LongWayActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent returnp = new Intent(LongWayActivity.this, PersonalCenterActivity.class); returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(returnp);/*w w w . j av a2s . c om*/ return false; } else { return super.onKeyDown(keyCode, event); } }
From source file:com.xorcode.andtweet.PreferencesActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && overrideBackButton) { finish();/*w ww . ja v a 2 s.c om*/ this.sendBroadcast(new Intent(this, TweetListActivity.class)); return true; } // TODO Auto-generated method stub return super.onKeyDown(keyCode, event); }
From source file:com.ichi2.anki2.Reviewer.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Log.i(AnkiDroidApp.TAG, "Reviewer - onBackPressed()"); closeReviewer(RESULT_DEFAULT, false); return true; }/*from w ww .j ava 2s .c om*/ /** Enhancement 722: Hardware buttons for scrolling, I.Z. */ if (!mCurrentSimpleInterface) { if (keyCode == 92) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (keyCode == 93) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } if (mScrollingButtons && keyCode == 94) { mCard.pageUp(false); if (mDoubleScrolling) { mCard.pageUp(false); } return true; } if (mScrollingButtons && keyCode == 95) { mCard.pageDown(false); if (mDoubleScrolling) { mCard.pageDown(false); } return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java
@Override public boolean onKeyDown(int keyCode, KeyEvent keyEvent) { if (keyCode == KeyEvent.KEYCODE_BACK && mPulldown.isSliderOpen() && !clingActive) { mPulldown.animateSliderClosed(); return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && mPager != null && !getBasicVisibility() && CalculatorSettings.basicPanel(getContext()) && !clingActive) { mPager.setCurrentItem(Panel.BASIC.getOrder()); return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && mSmallPager != null && mLargePager != null && !(getAdvancedVisibility() && getBasicVisibility()) && CalculatorSettings.basicPanel(getContext()) && CalculatorSettings.advancedPanel(getContext()) && !clingActive) { mSmallPager.setCurrentItem(SmallPanel.ADVANCED.getOrder()); mLargePager.setCurrentItem(LargePanel.BASIC.getOrder()); return true; }//www .j av a2 s . c o m return super.onKeyDown(keyCode, keyEvent); }
From source file:com.zen.androidhtmleditor.AHEActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Button discon = (Button)findViewById(R.id.backButton); //int visibility = discon.getVisibility(); if (folderPath.length() > 1 && connectedTo > -1) { String[] pathBits = folderPath.split("/"); folderPath = ""; for (int i = 0; i < pathBits.length - 1; i++) { folderPath += pathBits[i] + "/"; }/*from w w w . j av a2 s. c om*/ arrayAdapter.clear(); //connectedTo SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new MyFetchTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port).execute(); } else if (l.sftp.equals("3")) { new FetchSSLTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port).execute(); } } } } else if (connectedTo > -1) { disconnect(); } else { finish(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // //? gotoback();/*from w w w. j a v a 2 s . c o m*/ } return super.onKeyDown(keyCode, event); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public boolean onKeyDown(final int keyEventKeyCode, @NonNull KeyEvent event) { InputConnection ic = getCurrentInputConnection(); if (handleSelectionExpending(keyEventKeyCode, ic, mGlobalSelectionStartPosition, mGlobalCursorPosition)) return true; final boolean shouldTranslateSpecialKeys = isInputViewShown(); //greater than zero means it is a physical keyboard. //we also want to hide the view if it's a glyph (for example, not physical volume-up key) if (event.getDeviceId() > 0 && event.isPrintingKey()) onPhysicalKeyboardKeyPressed();/*w w w .j a v a 2s . c o m*/ mHardKeyboardAction.initializeAction(event, mMetaState); switch (keyEventKeyCode) { /**** * SPECIAL translated HW keys If you add new keys here, do not forget * to add to the */ case KeyEvent.KEYCODE_CAMERA: if (shouldTranslateSpecialKeys && mAskPrefs.useCameraKeyForBackspaceBackword()) { handleBackWord(getCurrentInputConnection()); return true; } // DO NOT DELAY CAMERA KEY with unneeded checks in default mark return super.onKeyDown(keyEventKeyCode, event); case KeyEvent.KEYCODE_FOCUS: if (shouldTranslateSpecialKeys && mAskPrefs.useCameraKeyForBackspaceBackword()) { handleDeleteLastCharacter(false); return true; } // DO NOT DELAY FOCUS KEY with unneeded checks in default mark return super.onKeyDown(keyEventKeyCode, event); case KeyEvent.KEYCODE_VOLUME_UP: if (shouldTranslateSpecialKeys && mAskPrefs.useVolumeKeyForLeftRight()) { sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_LEFT); return true; } // DO NOT DELAY VOLUME UP KEY with unneeded checks in default // mark return super.onKeyDown(keyEventKeyCode, event); case KeyEvent.KEYCODE_VOLUME_DOWN: if (shouldTranslateSpecialKeys && mAskPrefs.useVolumeKeyForLeftRight()) { sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_RIGHT); return true; } // DO NOT DELAY VOLUME DOWN KEY with unneeded checks in default // mark return super.onKeyDown(keyEventKeyCode, event); /**** * END of SPECIAL translated HW keys code section */ case KeyEvent.KEYCODE_BACK: if (event.getRepeatCount() == 0 && getInputView() != null) { if (getInputView().handleBack()) { // consuming the meta keys if (ic != null) { // translated, so we also take care of the metakeys ic.clearMetaKeyStates(Integer.MAX_VALUE); } mMetaState = 0; return true; } } break; case 0x000000cc:// API 14: KeyEvent.KEYCODE_LANGUAGE_SWITCH switchToNextPhysicalKeyboard(ic); return true; case KeyEvent.KEYCODE_SHIFT_LEFT: case KeyEvent.KEYCODE_SHIFT_RIGHT: if (event.isAltPressed() && Workarounds.isAltSpaceLangSwitchNotPossible()) { switchToNextPhysicalKeyboard(ic); return true; } // NOTE: letting it fall-through to the other meta-keys case KeyEvent.KEYCODE_ALT_LEFT: case KeyEvent.KEYCODE_ALT_RIGHT: case KeyEvent.KEYCODE_SYM: Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyDown before handle")); mMetaState = MyMetaKeyKeyListener.handleKeyDown(mMetaState, keyEventKeyCode, event); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyDown after handle")); break; case KeyEvent.KEYCODE_SPACE: if ((event.isAltPressed() && !Workarounds.isAltSpaceLangSwitchNotPossible()) || event.isShiftPressed()) { switchToNextPhysicalKeyboard(ic); return true; } // NOTE: // letting it fall through to the "default" default: // Fix issue 185, check if we should process key repeat if (!mAskPrefs.getUseRepeatingKeys() && event.getRepeatCount() > 0) return true; HardKeyboardTranslator keyTranslator = (HardKeyboardTranslator) getCurrentAlphabetKeyboard(); if (getKeyboardSwitcher().isCurrentKeyboardPhysical() && keyTranslator != null) { // sometimes, the physical keyboard will delete input, and then add some. // we'll try to make it nice. if (ic != null) ic.beginBatchEdit(); try { // issue 393, backword on the hw keyboard! if (mAskPrefs.useBackword() && keyEventKeyCode == KeyEvent.KEYCODE_DEL && event.isShiftPressed()) { handleBackWord(ic); return true; } else { // http://article.gmane.org/gmane.comp.handhelds.openmoko.android-freerunner/629 keyTranslator.translatePhysicalCharacter(mHardKeyboardAction, this); if (mHardKeyboardAction.getKeyCodeWasChanged()) { final int translatedChar = mHardKeyboardAction.getKeyCode(); // typing my own. onKey(translatedChar, null, -1, new int[] { translatedChar }, true/*faking from UI*/); // my handling we are at a regular key press, so we'll update // our meta-state member mMetaState = MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyDown after adjust - translated")); return true; } } } finally { if (ic != null) ic.endBatchEdit(); } } if (event.isPrintingKey()) { // we are at a regular key press, so we'll update our // meta-state // member mMetaState = MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState); Logger.d(TAG + "-meta-key", getMetaKeysStates("onKeyDown after adjust")); } } return super.onKeyDown(keyEventKeyCode, event); }