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.aujur.ebookreader.activity.ReadingFragment.java
public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); LOG.debug("Got key event: " + keyCode + " with action " + action); if (searchMenuItem != null && searchMenuItem.isActionViewExpanded()) { boolean result = searchMenuItem.getActionView().dispatchKeyEvent(event); if (result) { return true; }/*from w w w. j a v a 2s .c o m*/ } final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP = 92; final int KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM = 93; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP = 94; final int KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM = 95; boolean nook_touch_up_press = false; if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating(); return true; } /* * Tricky bit of code here: if we are NOT running TTS, we want to be * able to start it using the play/pause button. * * When we ARE running TTS, we'll get every media event twice: once * through the receiver and once here if focused. * * So, we only try to read media events here if tts is running. */ if (!ttsIsRunning() && dispatchMediaKeyEvent(event)) { return true; } LOG.debug("Key event is NOT a media key event."); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return handleVolumeButtonEvent(event); case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); updateFromPrefs(); return true; } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } } return false; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_TOP: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_TOP: nook_touch_up_press = true; case KEYCODE_NOOK_TOUCH_BUTTON_LEFT_BOTTOM: case KEYCODE_NOOK_TOUCH_BUTTON_RIGHT_BOTTOM: if (!Configuration.IS_NOOK_TOUCH || action == KeyEvent.ACTION_UP) return false; if (nook_touch_up_press == config.isNookUpButtonForward()) pageDown(Orientation.HORIZONTAL); else pageUp(Orientation.HORIZONTAL); return true; } LOG.debug("Not handling key event: returning false."); return false; }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mWiz.getPosition() == 3) { mWiz.goBack();/* www . j a va 2 s .c om*/ return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.jtschohl.androidfirewall.MainActivity.java
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { // Handle the back button when dirty if (this.dirty && (keyCode == KeyEvent.KEYCODE_BACK)) { final DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override// w ww . j a v a2 s . c om public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: applyOrSaveRules(); finish(); break; case DialogInterface.BUTTON_NEGATIVE: // Propagate the event back to perform the desired // action MainActivity.super.onKeyDown(keyCode, event); finish(); break; } } }; final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.unsaved_changes).setMessage(R.string.unsaved_changes_message) .setPositiveButton(R.string.apply, dialogClickListener) .setNegativeButton(R.string.discard, dialogClickListener).show(); // Say that we've consumed the event return true; } return super.onKeyDown(keyCode, event); }
From source file:com.efithealth.app.activity.ChatActivity.java
/** * /*from w w w . j a v a 2 s. c om*/ */ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (panel_root.getVisibility() != View.GONE) { KPSwitchConflictUtil.hidePanelAndKeyboard(panel_root); panel_root.setVisibility(View.GONE); return true; } } return super.dispatchKeyEvent(event); }
From source file:dev.memento.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // Back button goes back to previous page or memento if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebview.canGoBack()) { // Get the previous URL to update our internal copy WebBackForwardList list = mWebview.copyBackForwardList(); int curr = list.getCurrentIndex(); WebHistoryItem item = list.getItemAtIndex(curr - 1); String url = item.getUrl(); if (Log.LOG) Log.d(LOG_TAG, "GO BACK TO " + url); mWebview.goBack();/*from w w w . j a v a 2 s.co m*/ // Reset to today because it might be confusing to set to other dates setChosenDate(mToday); // Just in case mMementoProgressBar.setVisibility(View.GONE); if (Log.LOG) Log.d(LOG_TAG, "mWebHistory size = " + mWebHistory.size()); if (mWebHistory.isEmpty()) { if (Log.LOG) Log.e(LOG_TAG, "Stack maintaining page dates is empty!"); } else { ExWebHistoryItem item2 = mWebHistory.pop(); // Remove current if (Log.LOG) Log.d(LOG_TAG, "!! Removed item " + item2 + " from stack"); if (!mWebHistory.isEmpty()) { item2 = mWebHistory.peek(); // Previous if (Log.LOG) Log.d(LOG_TAG, "!! Top item is " + item2); } mCurrentMemento = item2.getMemento(); if (Log.LOG) Log.d(LOG_TAG, "mCurrentMemento = " + mCurrentMemento); if (mCurrentMemento == null) mDateDisplayed = mToday; else mDateDisplayed = mCurrentMemento.getDateTime(); if (Log.LOG) Log.d(LOG_TAG, "!! Back to date " + mDateDisplayed); refreshDisplayedDate(); // Indicate the user pressed the back button mUserPressedBack = true; // Should be able to press if it's not today mNowButton.setEnabled(mToday.compareDateTo(mDateDisplayed) != 0); //if (mCurrentMemento != null && !mCurrentMemento.getUrl().equals(url) && // !url.equals(mOriginalUrl)) { if (!mOriginalUrl.equals(item2.getOriginalUrl())) { mOriginalUrl = item2.getOriginalUrl(); if (Log.LOG) Log.d(LOG_TAG, "** Clearing list of old mementos"); if (Log.LOG) Log.d(LOG_TAG, "mOriginalUrl = " + mOriginalUrl); mMementos.clear(); } } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log.d("keycode", u.s(keyCode)); Log.d("tab", u.s(KeyEvent.KEYCODE_TAB)); if (keyCode == KeyEvent.KEYCODE_BACK) { return true; }// w w w . j av a 2s. co m return false; }
From source file:com.grass.caishi.cc.activity.main.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (isTaskRoot()) { moveTaskToBack(false);/*from w ww . j a v a 2s .c om*/ } else { moveTaskToBack(true); } return true; } return super.onKeyDown(keyCode, event); }
From source file:study.tdcc.act.MainCalendar.java
/** * ??// w ww .j ava2 s. c o m * * @param kEvent * @return ?????true */ @Override public boolean dispatchKeyEvent(KeyEvent kEvent) { Log.d("DEBUG", "MainCalendar dispatchKeyEvent Start"); //????? if (kEvent.getAction() == KeyEvent.ACTION_DOWN) { //????? if (kEvent.getKeyCode() == KeyEvent.KEYCODE_BACK) { //?yes/no? showYesNoDialog(this, R.string.mes1_dialog, R.string.mes2_dialog, new DialogInterface.OnClickListener() { //?? public void onClick(DialogInterface dialog, int whith) { if (whith == DialogInterface.BUTTON_POSITIVE) { // endActivity(); } else if (whith == DialogInterface.BUTTON_NEGATIVE) { // return; } } }); } } Log.d("DEBUG", "MainCalendar dispatchKeyEvent End"); return super.dispatchKeyEvent(kEvent); }
From source file:cm.aptoide.pt.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { View v = availableListView.getChildAt(0); scrollMemory.put(depth, new ListViewPosition((v == null) ? 0 : v.getTop(), availableListView.getFirstVisiblePosition())); if (!ApplicationAptoide.MULTIPLESTORES) { if (!depth.equals(ListDepth.CATEGORY1) && pager.getCurrentItem() == 1) { if (depth.equals(ListDepth.TOPAPPS) || depth.equals(ListDepth.LATEST_LIKES) || depth.equals(ListDepth.LATESTAPPS) || depth.equals(ListDepth.LATEST_COMMENTS) || depth.equals(ListDepth.RECOMMENDED) || depth.equals(ListDepth.ALLAPPLICATIONS)) { depth = ListDepth.CATEGORY1; } else { depth = ListDepth.values()[depth.ordinal() - 1]; }//from www. ja v a2 s .co m removeLastBreadCrumb(); refreshAvailableList(true); return false; } } else { if (!depth.equals(ListDepth.STORES) && pager.getCurrentItem() == 1) { if (depth.equals(ListDepth.TOPAPPS) || depth.equals(ListDepth.LATEST_LIKES) || depth.equals(ListDepth.LATESTAPPS) || depth.equals(ListDepth.LATEST_COMMENTS) || depth.equals(ListDepth.RECOMMENDED) || depth.equals(ListDepth.ALLAPPLICATIONS)) { depth = ListDepth.CATEGORY1; } else { depth = ListDepth.values()[depth.ordinal() - 1]; } removeLastBreadCrumb(); refreshAvailableList(true); return false; } } } if (ApplicationAptoide.isRestartLauncher()) { ApplicationAptoide.restartLauncher(MainActivity.this); ApplicationAptoide.setRestartLauncher(false); } return super.onKeyDown(keyCode, event); }
From source file:com.dmsl.anyplace.UnifiedNavigationActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: finish();/* w w w.j a v a 2s.c o m*/ return true; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_SEARCH: // Handle these events so they don't launch the Camera app return true; } return super.onKeyDown(keyCode, event); }