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:net.evecom.androidecssp.activity.event.ContinueAddActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { Intent intent = new Intent(); setResult(4, intent);/*from ww w . j a v a2 s.c o m*/ finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.javielinux.tweettopics2.TweetActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (popupLinks.isShowLinks()) { popupLinks.hideLinks();// w w w . j a va 2 s .c o m return false; } if (splitActionBarMenu.isShowing()) { splitActionBarMenu.hideSplitActionBarMenu(); return false; } } return super.onKeyDown(keyCode, event); }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) { webView.goBack();//from w w w .j a va2 s. c o m return true; } return super.onKeyDown(keyCode, event); }
From source file:com.bookkos.bircle.CaptureActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED);// w w w . j a v a2s.c o m finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: return true; // Use volume up/down to turn on light // case KeyEvent.KEYCODE_VOLUME_DOWN: // cameraManager.setTorch(false); // return true; // case KeyEvent.KEYCODE_VOLUME_UP: // cameraManager.setTorch(true); // return true; } return super.onKeyDown(keyCode, event); }
From source file:com.github.akinaru.rfdroid.activity.BtDevicesActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) { if (scanningListView.getVisibility() == View.VISIBLE) { onBackPressed();//from w w w . j a v a2s.c om } else { if (currentService.isScanning()) { hideProgressBar(); currentService.stopScan(); } mScanIntervalSeekbar.setVisibility(View.GONE); mWindowIntervalSeekbar.setVisibility(View.GONE); scanningListView.setVisibility(View.VISIBLE); if (deviceNameTv != null) deviceNameTv.setVisibility(View.GONE); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.holo.fileexplorer.MainActivity.java
/** * KeyDown/KeyUp code derived from//from w ww. j a v a 2 s. co m * http://developer.android.com/sdk/android-2.0.html (read very bottom of * page) * <p> * The user may tap the back button, but then drag off of the button to * avoid a button press * * @see android.support.v4.app.FragmentActivity#onKeyDown(int, * android.view.KeyEvent) * * */ public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { event.startTracking(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.example.android.Game.java
/** * onKeyDown overrides onKeyDown and allows code to be executed when the * back button is pushed in the simulator / on the mobile phone Since * pushing "back" won't necessarily call the destroy method as far as I * understand it.//from w ww . java 2 s.c o m * * @param keyCode * : code of the key pressed * @param event * : the event for the key pressed */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == zero) { //This code cannot be in onStop in Game because //it also kills the applause noise as GameEnd begins // cancel any noises and abandon focus SoundPlayer.stop(); if (focusHelper != null) { focusHelper.abandonFocus(); } // continue backwards (kills current activity) finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.holo.fileexplorer.MainActivity.java
/** * /*from w w w .j a v a2s. co m*/ */ public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking() && !event.isCanceled()) { // *** DO ACTION HERE *** if (mViewPager.getFragment(mPager, mPager.getCurrentItem()).backOneLevel()) { return true; } else { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert) .setMessage("Quit the application?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // android.os.Debug.stopMethodTracing(); finish(); } }).setNegativeButton("No", null).show(); } return true; } return super.onKeyUp(keyCode, event); }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment.java
/** * For keyboard mode, processes key events. * * @param keyCode the pressed key.//from w w w . j a v a 2 s . 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) { 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); } doneClickValidateAndCallback(); 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)); } Utils.tryAccessibilityAnnounce(mTimePicker, 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; }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (isShowOptionsColumns()) { hideOptionsColumns();// ww w . java 2 s. c om return false; } if (popupLinks.isShowLinks()) { popupLinks.hideLinks(); return false; } if (splitActionBarMenu.isShowing()) { splitActionBarMenu.hideSplitActionBarMenu(); return false; } if (isShowColumnsItems) { showActionBarIndicatorAndMovePager(-1); return false; } } if (keyCode == KeyEvent.KEYCODE_MENU) { goToColumn(0, false, -1); } return super.onKeyDown(keyCode, event); }