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.moodmap.HomeActivity.java
@Override public boolean onKeyDown(int keyCode, android.view.KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // Kill the app from back on Mood Entry, it is topmost. // Needed because a notification open can cause back to point to // weird places. - STC 12/27/11 this.finish(); return true; }// w w w.j a v a 2 s .co m return false; }
From source file:com.example.photoremark.MainActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { onExit();/* www . ja v a 2 s .c o m*/ } } return true; }
From source file:com.google.zxing.client.android.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 .java 2s . co m*/ finish(); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app 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:es.uja.photofirma.android.SignUpActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { finish();/*from ww w. j a va2s .c o m*/ overridePendingTransition(R.anim.right_in, R.anim.right_out); } return false;// super.onKeyDown(keyCode, event); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { new AlertDialog.Builder(CloudletActivity.this).setTitle("Exit").setMessage("Finish Application") .setPositiveButton("Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { moveTaskToBack(true); finish();// w ww.ja va 2 s .c om } }).setNegativeButton("Cancel", null).show(); } return super.onKeyDown(keyCode, event); }
From source file:com.android.tv.tuner.setup.TunerSetupActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { FragmentManager manager = getFragmentManager(); int count = manager.getBackStackEntryCount(); if (count > 0) { String lastTag = manager.getBackStackEntryAt(count - 1).getName(); if (ScanResultFragment.class.getCanonicalName().equals(lastTag) && count >= 2) { // Pops fragment including ScanFragment. manager.popBackStack(manager.getBackStackEntryAt(count - 2).getName(), FragmentManager.POP_BACK_STACK_INCLUSIVE); return true; } else if (ScanFragment.class.getCanonicalName().equals(lastTag)) { mLastScanFragment.finishScan(true); return true; }/*from ww w .ja va2 s.c o m*/ } } return super.onKeyUp(keyCode, event); }
From source file:com.conduit.plastic.ui.main.activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { long secondTime = System.currentTimeMillis(); if (keyCode == KeyEvent.KEYCODE_BACK) { if (mAlertDialog != null && mAlertDialog.isShowing()) { Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show(); } else {/*from w ww .j a va2s.c o m*/ if (secondTime - firstTime < 2000) { System.exit(0); } else { Toast.makeText(MainActivity.this, "??", Toast.LENGTH_SHORT).show(); firstTime = System.currentTimeMillis(); } } return true; } return super.onKeyDown(keyCode, event); }
From source file:ael.com.loterias.c_login.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { c_logging.getInstance().log(c_logging.LOG_INFO, getString(R.string.st_la_Exit)); PRC_INTENTAR_SALIR();/* www . j a v a2 s . c o m*/ // Si el listener devuelve true, significa que el evento esta // procesado, y nadie debe hacer nada mas return true; } // para las demas cosas, se reenvia el evento al listener habitual return super.onKeyDown(keyCode, event); }
From source file:org.esupportail.nfctagdroid.NfcTacDroidActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.exit) .setMessage(R.string.msg_exit) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override/*from w w w . j av a 2 s . co m*/ public void onClick(DialogInterface dialog, int which) { finish(); Process.killProcess(Process.myPid()); System.exit(1); } }).setNegativeButton(R.string.no, null).show(); } return true; }
From source file:com.app.blockydemo.ui.ScriptActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { //Dismiss ActionMode without effecting checked items FormulaEditorVariableListFragment formulaEditorVariableListFragment = (FormulaEditorVariableListFragment) getSupportFragmentManager() .findFragmentByTag(FormulaEditorVariableListFragment.VARIABLE_TAG); if (formulaEditorVariableListFragment != null) { if (formulaEditorVariableListFragment.isVisible()) { ListAdapter adapter = formulaEditorVariableListFragment.getListAdapter(); ((ScriptActivityAdapterInterface) adapter).clearCheckedItems(); return super.dispatchKeyEvent(event); }//from w w w . jav a 2 s. c o m } if (currentFragment != null && currentFragment.getActionModeActive()) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { ListAdapter adapter = null; if (currentFragment instanceof ScriptFragment) { adapter = ((ScriptFragment) currentFragment).getAdapter(); } else { adapter = currentFragment.getListAdapter(); } ((ScriptActivityAdapterInterface) adapter).clearCheckedItems(); } } return super.dispatchKeyEvent(event); }