Example usage for android.view KeyEvent KEYCODE_BACK

List of usage examples for android.view KeyEvent KEYCODE_BACK

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_BACK.

Prototype

int KEYCODE_BACK

To view the source code for android.view KeyEvent KEYCODE_BACK.

Click Source Link

Document

Key code constant: Back key.

Usage

From source file:com.wso2.mobile.mdm.DisplayDeviceInfoActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && FROM_ACTIVITY != null
            && FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
        Intent intent = new Intent(DisplayDeviceInfoActivity.this, AlreadyRegisteredActivity.class);
        intent.putExtra(getResources().getString(R.string.intent_extra_from_activity),
                DisplayDeviceInfoActivity.class.getSimpleName());
        intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID);
        startActivity(intent);/*  ww  w . j  a  va  2 s  .  com*/
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_HOME);
        this.startActivity(i);
        this.finish();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
        webView.goBack();//from   w w w  . j av a2  s .c om
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:br.com.anteros.vendas.gui.PedidoCadastroActivity.java

/**
 * Evento tecla pressionada//from   w  w  w .j a  va2s  .c  o m
 * @param keyCode Cdigo da tecla
 * @param event Evento
 * @return True para propagar evento.
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        cancelarPedido();
    }
    return super.onKeyDown(keyCode, event);
}

From source file:mobisocial.musubi.webapp.WebAppActivity.java

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    //provide an override to escape
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        finish();/*from  ww w . j ava 2  s .co  m*/
    }
    return super.onKeyLongPress(keyCode, event);
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorListFragment.java

@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
    FormulaEditorFragment formulaEditor = (FormulaEditorFragment) getActivity().getSupportFragmentManager()
            .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
    if (formulaEditor != null) {
        formulaEditor.addResourceToActiveFormula(itemsIds[position]);
        formulaEditor.updateButtonViewOnKeyboard();
    }/*from  www  . j  av  a  2s . c o m*/
    KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
    onKey(null, keyEvent.getKeyCode(), keyEvent);
}

From source file:com.hichinaschool.flashcards.anki.Feedback.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        deleteFiles(true, false);//from   w ww. j a  va2s . co m
        closeFeedback();
    }
    return super.onKeyDown(keyCode, event);
}

From source file:be.ac.ucl.lfsab1509.llncampus.activity.WebviewActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && history.size() > 1) {
        history.pop(); // Remove the current page.
        HistoryElement he = history.peek(); // Get the previous page.
        updateHTML(he.baseURL, he.html, he.customCSS, true);
        return true;
    }/*from   w  w  w.ja  v  a2  s .c o  m*/
    return super.onKeyDown(keyCode, event);
}

From source file:com.inha.stickyonpage.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (getSupportFragmentManager().findFragmentByTag("BrowsingWebView") != null) {
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT) || mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                mDrawerLayout.closeDrawer(Gravity.RIGHT);
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                return false;
            } else {
                WebView mWebView = (WebView) findViewById(R.id.webView1);
                if (mWebView.canGoBack()) {
                    mWebView.goBack();//from w  w w  .j  ava2s . c  om
                } else {
                    ActionBar mActionBar = getActionBar();
                    mActionBar.setCustomView(null);
                    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);
                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    RecentStickyView stickyFragment = new RecentStickyView();
                    ft.replace(R.id.drawer_main, stickyFragment, "RecentStickyView");
                    ft.commit();
                }
                return false;
            }
        } else if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
            if (!mFlag) {
                Toast.makeText(this, "''?  ?  ?.",
                        Toast.LENGTH_SHORT).show();
                mFlag = true;
                mHandler.sendEmptyMessageDelayed(0, 2000);
                return false;
            } else {
                finish();
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.android.projectz.teamrocket.thebusapp.activities.SearchLineActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        this.finish();
        SearchLineActivity.this.overridePendingTransition(R.anim.anim_slide_in_right,
                R.anim.anim_slide_out_right);
    }// w  w  w .j a  va  2  s. c om
    return true;
}

From source file:mobisocial.musubi.webapp.WebAppActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Check if the key event was the BACK key and if there's history
    if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
        mWebView.goBack();/*from ww w  .j a  v  a 2  s  .  c  o  m*/
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        mWebView.loadUrl("javascript:globalAppContext.back()");
        Log.w(TAG, "pressed back");
        return true;
    }
    // If it wasn't the BACK key or there's no web page history, bubble up to the default
    // system behavior (probably exit the activity)
    return super.onKeyUp(keyCode, event);
}