List of usage examples for android.view KeyEvent getRepeatCount
public final int getRepeatCount()
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();//from www.j a v a 2 s .c o m } 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 ww w .j a v a2s. 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:de.earthlingz.oerszebra.DroidZebra.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { mZebraThread.undoMove();// ww w .j ava 2 s.co m return true; } return super.onKeyDown(keyCode, event); }
From source file:org.openremote.android.console.GroupActivity.java
/** * If press back key, finish the activity. * /*ww w .java2s.c o m*/ * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent) */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.data.pack.ViewVideo.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Log.d("CDA", "onKeyDown Called"); // onBackPressed(); }/* www . j a v a 2s. c o m*/ return false;// 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 ww w . j a v a2 s . com*/ 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:dev.datvt.cloudtracks.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { exitApp();/*from w w w . j a va 2s .c o m*/ return true; } return super.onKeyDown(keyCode, event); }
From source file:org.wso2.cdm.agent.AuthenticationActivity.java
public void showAgreement(String message, String title) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_terms_popup); dialog.setTitle(CommonUtilities.EULA_TITLE); dialog.setCancelable(false);/* w ww. j av a 2s . c om*/ WebView web = (WebView) dialog.findViewById(R.id.webview); String html = "<html><body>" + message + "</body></html>"; String mime = "text/html"; String encoding = "utf-8"; web.loadDataWithBaseURL(null, html, mime, encoding, null); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); Button cancelButton = (Button) dialog.findViewById(R.id.dialogButtonCancel); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Preference.put(context, getResources().getString(R.string.shared_pref_isagreed), "1"); dialog.dismiss(); loadPincodeAcitvity(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); cancelEntry(); } }); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { return true; } return false; } }); dialog.show(); }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Take care of calling this method on earlier versions of // the platform where it doesn't exist. onBackPressed();/*from w w w. j a va2s.c o m*/ return true; } else { // Pass this onKeyDown event trough to the underlying fragments if (!getActiveDialog().onKeyDown(keyCode, event)) return super.onKeyDown(keyCode, event); else return true; } }
From source file:com.mobilevue.vod.VideoControllerView.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (mPlayer == null) { return true; }/*ww w . j a va 2s . com*/ int keyCode = event.getKeyCode(); final boolean uniqueDown = event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN; if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE) { if (uniqueDown) { doPauseResume(); show(sDefaultTimeout); if (mPauseButton != null) { mPauseButton.requestFocus(); } } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (uniqueDown && !mPlayer.isPlaying()) { mPlayer.start(); updatePausePlay(); show(sDefaultTimeout); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (uniqueDown && mPlayer.isPlaying()) { mPlayer.pause(); updatePausePlay(); show(sDefaultTimeout); } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { // don't show the controls for volume adjustment return super.dispatchKeyEvent(event); } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { if (uniqueDown) { hide(); } return true; } show(sDefaultTimeout); return super.dispatchKeyEvent(event); }