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.feytuo.chat.activity.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //??/*w w w . j a va 2 s . c o m*/ App.pre.edit().putInt(Global.CURRENT_NATIVE, 0).commit(); App.pre.edit().putBoolean(Global.IS_MAIN_LIST_NEED_REFRESH, true).commit(); moveTaskToBack(false); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.adnanbal.fxdedektifi.forex.presentation.view.activity.SignalsActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (this.getSupportFragmentManager().getBackStackEntryCount() <= 1) { AndroidApplication.backtackFragmentList.clear(); finish();/*from w w w. ja v a2 s . c om*/ return true; } else { if (AndroidApplication.backtackFragmentList.size() > 1) { AndroidApplication.backtackFragmentList .remove(AndroidApplication.backtackFragmentList.size() - 1); Integer checkedItem = AndroidApplication.backtackFragmentList .get(AndroidApplication.backtackFragmentList.size() - 1); if (checkedItem == 0) { getSupportActionBar().setTitle(R.string.signals); navigationViewDrawer.setCheckedItem(R.id.nav_item_signals_fragment); bottomNavigationView.setVisibility(View.VISIBLE); } else if (checkedItem == 1) { getSupportActionBar().setTitle(R.string.profit); navigationViewDrawer.setCheckedItem(R.id.nav_item_profit_fragment); bottomNavigationView.setVisibility(View.VISIBLE); } else if (checkedItem == 2) { getSupportActionBar().setTitle(R.string.my_account); navigationViewDrawer.setCheckedItem(R.id.nav_item_my_account_fragment); } else if (checkedItem == 3) { getSupportActionBar().setTitle(R.string.terms_and_conditions_lowerCase); uncheckAllMenuItems(navigationViewDrawer); bottomNavigationView.setVisibility(View.VISIBLE); } } getSupportFragmentManager().popBackStack(); return true; } // If there are no fragments on stack perform the original back button event } return super.onKeyDown(keyCode, event); }
From source file:edu.pitt.gis.uniapp.UniApp.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { //Determine if the focus is on the current view or not if (appView.getHitTestResult() != null && appView.getHitTestResult().getType() == WebView.HitTestResult.EDIT_TEXT_TYPE && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) { return appView.onKeyUp(keyCode, event); } else if (appView.isCustomViewShowing() && keyCode == KeyEvent.KEYCODE_BACK) { return appView.onKeyUp(keyCode, event); } else {/* w ww. j ava2s . c o m*/ return super.onKeyUp(keyCode, event); } }
From source file:com.onebus.view.MainActivity.java
/** * * ???? /*from w ww .j a v a2s. c o m*/ */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { exitBy2Click(); // ? } return false; }
From source file:edu.pitt.gis.uniapp.UniApp.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { //Determine if the focus is on the current view or not if (appView.getHitTestResult() != null && appView.getHitTestResult().getType() == WebView.HitTestResult.EDIT_TEXT_TYPE && keyCode == KeyEvent.KEYCODE_BACK) { return appView.onKeyDown(keyCode, event); } else/*w w w .ja v a2 s .c o m*/ return super.onKeyDown(keyCode, event); }
From source file:com.android.tv.ui.TvOverlayManager.java
/** * Handles the onKeyUp event of the {@link MainActivity}. *///from www .j av a 2 s .co m @KeyHandlerResultType public int onKeyUp(int keyCode, KeyEvent event) { // Handle media key here because it is related to the menu. if (isMediaStartKey(keyCode)) { // The media key should not be passed up to the system in any cases. if (mCurrentDialog != null || mProgramGuide.isActive() || mSideFragmentManager.isActive() || mSearchFragment.isVisible() || mTransitionManager.isKeypadChannelSwitchActive() || mTransitionManager.isSelectInputActive() || mSetupFragmentActive || mNewSourcesFragmentActive) { // Do not handle media key when any pop-ups which can handle keys are active. return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } TimeShiftManager timeShiftManager = mMainActivity.getTimeShiftManager(); if (!timeShiftManager.isAvailable()) { return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } switch (keyCode) { case KeyEvent.KEYCODE_MEDIA_PLAY: timeShiftManager.play(); showMenu(Menu.REASON_PLAY_CONTROLS_PLAY); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: timeShiftManager.pause(); showMenu(Menu.REASON_PLAY_CONTROLS_PAUSE); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: timeShiftManager.togglePlayPause(); showMenu(Menu.REASON_PLAY_CONTROLS_PLAY_PAUSE); break; case KeyEvent.KEYCODE_MEDIA_REWIND: timeShiftManager.rewind(); showMenu(Menu.REASON_PLAY_CONTROLS_REWIND); break; case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: timeShiftManager.fastForward(); showMenu(Menu.REASON_PLAY_CONTROLS_FAST_FORWARD); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: timeShiftManager.jumpToPrevious(); showMenu(Menu.REASON_PLAY_CONTROLS_JUMP_TO_PREVIOUS); break; case KeyEvent.KEYCODE_MEDIA_NEXT: timeShiftManager.jumpToNext(); showMenu(Menu.REASON_PLAY_CONTROLS_JUMP_TO_NEXT); break; default: // Does nothing. break; } return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } if (keyCode == KeyEvent.KEYCODE_I || keyCode == KeyEvent.KEYCODE_TV_INPUT) { if (mTransitionManager.isSelectInputActive()) { mSelectInputView.onKeyUp(keyCode, event); } else { showSelectInputView(); } return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } if (mCurrentDialog != null) { // Consumes the keys while a Dialog is showing. // This can be happen while a Dialog isn't created yet. return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } if (mProgramGuide.isActive()) { if (keyCode == KeyEvent.KEYCODE_BACK) { mProgramGuide.onBackPressed(); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY; } if (mSideFragmentManager.isActive()) { if (keyCode == KeyEvent.KEYCODE_BACK || mSideFragmentManager.isHideKeyForCurrentPanel(keyCode)) { mSideFragmentManager.popSideFragment(); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY; } if (mMenu.isActive() || mTransitionManager.isSceneActive()) { if (keyCode == KeyEvent.KEYCODE_BACK) { TimeShiftManager timeShiftManager = mMainActivity.getTimeShiftManager(); if (timeShiftManager.isPaused()) { timeShiftManager.play(); } hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANELS | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_DIALOG | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } if (mMenu.isActive()) { if (KeypadChannelSwitchView.isChannelNumberKey(keyCode)) { mMainActivity.showKeypadChannelSwitchView(keyCode); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY; } } if (mTransitionManager.isKeypadChannelSwitchActive()) { if (keyCode == KeyEvent.KEYCODE_BACK) { mTransitionManager.goToEmptyScene(true); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return mKeypadChannelSwitchView.onKeyUp(keyCode, event) ? MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED : MainActivity.KEY_EVENT_HANDLER_RESULT_NOT_HANDLED; } if (mTransitionManager.isSelectInputActive()) { if (keyCode == KeyEvent.KEYCODE_BACK) { mTransitionManager.goToEmptyScene(true); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return mSelectInputView.onKeyUp(keyCode, event) ? MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED : MainActivity.KEY_EVENT_HANDLER_RESULT_NOT_HANDLED; } if (mSetupFragmentActive) { if (keyCode == KeyEvent.KEYCODE_BACK) { closeSetupFragment(true); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY; } if (mNewSourcesFragmentActive) { if (keyCode == KeyEvent.KEYCODE_BACK) { closeNewSourcesFragment(true); return MainActivity.KEY_EVENT_HANDLER_RESULT_HANDLED; } return MainActivity.KEY_EVENT_HANDLER_RESULT_DISPATCH_TO_OVERLAY; } return MainActivity.KEY_EVENT_HANDLER_RESULT_PASSTHROUGH; }
From source file:com.lover.main.ResideMenu.main.MainActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // ???/*from w w w .jav a 2 s. c o m*/ if (is_closed) { // 2 if ((System.currentTimeMillis() - mExitTime) > 2000) { Toast.makeText(this, "??", Toast.LENGTH_SHORT).show(); mExitTime = System.currentTimeMillis(); } else { System.exit(0); finish(); moveTaskToBack(false);// super.onBackPressed(); } // // HOME???? // Intent i = new Intent(Intent.ACTION_MAIN); // i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // i.addCategory(Intent.CATEGORY_HOME); // startActivity(i); } else { resideMenu.closeMenu(); } return true; } return super.onKeyDown(keyCode, event); }
From source file:com.easemob.chatuidemo.activity.ChatMainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // moveTaskToBack(false); finish();// ww w. j a v a 2 s . com return true; } return super.onKeyDown(keyCode, event); }
From source file:com.grass.caishi.cc.activity.SettingUserActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { // ?//from w w w . j a v a 2 s. c om if (isRefresh) { Intent it = new Intent(); it.putExtra("info", userInfo); setResult(888, it); finish(); } } return super.onKeyDown(keyCode, event); }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { String message = getResources().getString(R.string.exitOnBackButtonPressed); if (keyCode == KeyEvent.KEYCODE_BACK) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message).setCancelable(false).setPositiveButton( getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface iDialog, int id) { stopService(new Intent(context, DeviceMonitorService.class)); // Unregistering the broadcast receivers // unregisterReceiver(bReceiver); unregisterReceiver(mConnReceiver); unregisterReceiver(wifiReceiver); if (connected) { close = true; /* * The progress dialog is not created by * the AsyncTask because the peer just * sends a message to the bootstrap. * This takes very few time and the * dialog would disappear almost * immediately. By showing it before * executing the AsyncTask, it can stay * on the screen until the bootstrap * informs the peer that it is part of * the network. Thus, the dialog is * removed from the function listening * for received messages * onReceivedMessage(String). *//*from w w w . j a va2 s.c o m*/ dialog = new ProgressDialog(NAM4JAndroidActivity.this); dialog.setMessage(NAM4JAndroidActivity.this.getString(R.string.pwLeaving)); dialog.show(); new LeaveNetwork(null).execute(); connected = false; } else { // finish(); // AFTER LEAVING THE NETWORK, THE APP GETS CLOSED /* * Notify the system to finalize and * collect all objects of the app on * exit so that the virtual machine * running the app can be killed by the * system without causing issues. * * NOTE: If this is set to true then the * virtual machine will not be killed * until all of its threads have closed. */ System.runFinalizersOnExit(true); /* * Force the system to close the app * down completely instead of retaining * it in the background. The virtual * machine that runs the app will be * killed. The app will be completely * created as a new app in a new virtual * machine running in a new process if * the user starts the app again. */ System.exit(0); } } }).setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } else if (keyCode == KeyEvent.KEYCODE_MENU) { displaySideMenu(); } return super.onKeyDown(keyCode, event); // return true; }