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.gsma.rcs.ri.sharing.video.OutgoingVideoSharing.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (KeyEvent.KEYCODE_BACK == keyCode) { if (LogUtils.isActive) { Log.d(LOGTAG, "Back key pressed"); }/* ww w . j av a2 s . c o m*/ try { if (mVideoSharing == null || !RcsSessionUtil.isAllowedToAbortVideoSharingSession(mVideoSharing)) { finish(); return true; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.label_confirm_close); builder.setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { quitSession(); } }); builder.setNegativeButton(R.string.label_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); builder.setCancelable(true); registerDialog(builder.show()); return true; } catch (RcsServiceException e) { showException(e); } } return super.onKeyDown(keyCode, event); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { finish();/*from w ww .j a v a 2s . c o m*/ return true; } return super.onKeyDown(keyCode, event); }
From source file:com.dldzkj.app.renxing.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { if ((System.currentTimeMillis() - exitTime) > 2000) { Toast.makeText(getApplicationContext(), "??", Toast.LENGTH_SHORT).show(); exitTime = System.currentTimeMillis(); } else {/*w ww .j a v a 2 s .c o m*/ System.exit(0); finish(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:br.com.thinkti.android.filechooserfrag.fragFileChooser.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if ((!currentDir.getName().equals("sdcard")) && (currentDir.getParentFile() != null)) { AlertDialog.Builder A = new AlertDialog.Builder(getActivity()); A.setPositiveButton(getString(R.string.yes), new AlertDialog.OnClickListener() { @Override/*from ww w. ja v a 2s.c o m*/ public void onClick(DialogInterface dialog, int which) { _main.mPager.setCurrentItem(_MainActivity.fragID); } }); A.setNegativeButton(getString(R.string.no), new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { currentDir = currentDir.getParentFile(); fill(currentDir); } }); A.setMessage(getString(R.string.close)); A.setTitle(_main.getString((R.string.question))); A.show(); } else { _main.mPager.setCurrentItem(_MainActivity.fragID); } return false; } return true; }
From source file:com.sdspikes.fireworks.FireworksActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent e) { if (keyCode == KeyEvent.KEYCODE_BACK && mCurScreen == R.id.screen_game) { leaveRoom();//from w w w.j a va2 s .co m return true; } return super.onKeyDown(keyCode, e); }
From source file:com.hichinaschool.flashcards.anki.CardBrowser.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()"); if (mSearchEditText.getText().length() == 0) { closeCardBrowser(Activity.RESULT_OK); } else {/*from w w w . j a va 2s .c o m*/ mSearchEditText.setText(""); mSearchEditText.setHint(R.string.downloaddeck_search); mSelectedTags.clear(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.google.appinventor.components.runtime.Form.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (!BackPressed()) { boolean handled = super.onKeyDown(keyCode, event); AnimationUtil.ApplyCloseScreenAnimation(this, closeAnimType); return handled; } else {/*from w ww . j av a 2 s .com*/ return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.kanchi.periyava.old.Activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Take care of calling this method on earlier versions of // the platform where it doesn't exist. getFragmentManager().popBackStack(); onBackPressed();/* w w w.jav a 2s . c o m*/ } return super.onKeyDown(keyCode, event); }
From source file:com.dnielfe.manager.Browser.java
@Override public boolean onKeyDown(int keycode, KeyEvent event) { if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && !mCurrentPath.equals("/")) { File file = new File(mCurrentPath); navigateTo(file.getParent());/*w w w. j a va 2s .com*/ // go to the top of the ListView mListView.setSelection(0); return true; } else if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && mCurrentPath.equals("/")) { Toast.makeText(Browser.this, getString(R.string.pressbackagaintoquit), Toast.LENGTH_SHORT).show(); mUseBackKey = false; return false; } else if (keycode == KeyEvent.KEYCODE_BACK && !mUseBackKey && mCurrentPath.equals("/")) { finish(); return false; } return super.onKeyDown(keycode, event); }
From source file:com.gcloud.gaadi.ui.sleepbot.datetimepicker.time.TimePickerDialog.java
/** * For keyboard mode, processes key events. * * @param keyCode the pressed key.// ww w. j a va 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) { 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()); } 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)); } 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. GCLog.e("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; }