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.vanco.abplayer.BiliVideoViewActivity.java

public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        long currentTime = System.currentTimeMillis();

        if ((currentTime - touchTime) >= EXIT_INTERVAL_TIME) {
            Toast.makeText(BiliVideoViewActivity.this, "?()~", 1).show();
            touchTime = currentTime;/*from  w  w w  .  j av  a 2s  .  c om*/
        } else {
            finish();
            if (mDanmakuView != null)
                mDanmakuView.release();
        }

        return false;
    } else {
        return true;
    }
}

From source file:flex.android.magiccube.activity.ActivityBattleMode.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        dialog2 = new DialogSetting(this, settinghandler);
        dialog2.show();// ww w.  j  ava2  s  .  c o  m
        return false;
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) {
        showExitGameAlert();
        return false;
    }
    return super.onKeyDown(keyCode, event);
    // return super.onKeyDown(keyCode, event);
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (event.getUnicodeChar() != 0) {
        if (!searchView.hasFocus()) {
            setSearchText("" + (char) event.getUnicodeChar(), true);
            searchView.requestFocus();//from   w  ww  .ja  v  a  2  s.c  o m
        }
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // Log.d(LOG, "Clearing dictionary prefs.");
        // Pretend that we just autolaunched so that we won't do it again.
        // DictionaryManagerActivity.lastAutoLaunchMillis =
        // System.currentTimeMillis();
    }
    if (keyCode == KeyEvent.KEYCODE_ENTER) {
        Log.d(LOG, "Trying to hide soft keyboard.");
        final InputMethodManager inputManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        View focus = getCurrentFocus();
        if (focus != null) {
            inputManager.hideSoftInputFromWindow(focus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && hasVisibleDrawer()) {
        event.startTracking();//from ww  w  .  j  av  a  2 s.c om
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        final View visibleDrawer = findVisibleDrawer();
        if (visibleDrawer != null/* && getDrawerLockMode(visibleDrawer) == LOCK_MODE_UNLOCKED*/) {
            closeDrawers();//from w ww  .  ja  v a  2 s . c  o  m
        }
        return visibleDrawer != null;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.android.ex.chips.RecipientEditTextView.java

/**
 * Dismiss any selected chips when the back key is pressed.
 *///from   w  ww .j  av  a  2s.  c o m
@Override
public boolean onKeyPreIme(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && mSelectedChip != null) {
        clearSelectedChip();
        return true;
    }
    return super.onKeyPreIme(keyCode, event);
}

From source file:es.upv.riromu.arbre.main.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {

        if (getFragmentManager().findFragmentByTag("first") != null) {
            getFragmentManager().popBackStack();
            removeCurrentFragment();// ww w.  j ava  2 s .c  om

            return false;

        }

        if (getFragmentManager().getBackStackEntryCount() == 0) {
            this.finish();
            return false;
        } else {
            getSupportFragmentManager().popBackStack();
            removeCurrentFragment();

            return false;
        }

    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.iiordanov.runsoft.bVNC.RemoteCanvasActivity.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent evt) {

    boolean consumed = false;
    if (keyCode == KeyEvent.KEYCODE_BACK && chat_layout.getVisibility() == View.VISIBLE) {

        chat_layout.setVisibility(View.GONE);
        return false;
    }/*  w  ww.j av a2 s . c  o m*/
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (evt.getAction() == KeyEvent.ACTION_DOWN)
            return super.onKeyDown(keyCode, evt);
        else
            return super.onKeyUp(keyCode, evt);
    }

    try {
        if (evt.getAction() == KeyEvent.ACTION_DOWN || evt.getAction() == KeyEvent.ACTION_MULTIPLE) {
            consumed = inputHandler.onKeyDown(keyCode, evt);
        } else if (evt.getAction() == KeyEvent.ACTION_UP) {
            consumed = inputHandler.onKeyUp(keyCode, evt);
        }

        resetOnScreenKeys(keyCode);
    } catch (NullPointerException e) {
    }

    return consumed;
}

From source file:com.efithealth.app.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {

        return returnBack();
    }//from w  w w .  ja  va 2 s  . c o  m
    return super.onKeyDown(keyCode, event);
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        showchecksdialog();//w w  w .  j a va 2s .  c o m
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_FLOORPLAN);
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_ASSETINFO);
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_ASSETINFO);
        Tabs1.db.showfulldblog(Tabs1.db.TABLE_ASSETINFO);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}