Example usage for android.view KeyEvent KEYCODE_BUTTON_B

List of usage examples for android.view KeyEvent KEYCODE_BUTTON_B

Introduction

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

Prototype

int KEYCODE_BUTTON_B

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

Click Source Link

Document

Key code constant: B Button key.

Usage

From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
        //fall through
    case KeyEvent.KEYCODE_BUTTON_A:
        if (mIsPlaying) {
            mElfAccelY = 0.0f;//from  w ww.  j  av a 2  s . c o m
            if (!mElfIsHit) {
                updateElfThrust(0);
            }
            if (mJetThrustStream > 0) {
                mSoundPool.stop(mJetThrustStream);
                mJetThrustStream = 0;
            }
        } else if (mMoviePlaying) {
            endIntro();
        } else if (mBigPlayButton.isPressed()) {
            mBigPlayButton.setPressed(false);
            mBigPlayButton.performClick();
        }
        return true;
    case KeyEvent.KEYCODE_BUTTON_B:
        onBackPressed();
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.android.tv.MainActivity.java

private boolean dispatchKeyEventToSession(final KeyEvent event) {
    if (SystemProperties.LOG_KEYEVENT.getValue()) {
        Log.d(TAG, "dispatchKeyEventToSession(" + event + ")");
    }//ww w .  j a v  a2s . c o  m
    if (mPipEnabled && mChannelTuner.isCurrentChannelPassthrough()) {
        // If PIP is enabled, key events will be used by UI.
        return false;
    }
    boolean handled = false;
    if (mTvView != null) {
        handled = mTvView.dispatchKeyEvent(event);
    }
    if (isKeyEventBlocked()) {
        if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK || event.getKeyCode() == KeyEvent.KEYCODE_BUTTON_B)
                && mNeedShowBackKeyGuide) {
            // KeyEvent.KEYCODE_BUTTON_B is also used like the back button.
            Toast.makeText(this, R.string.msg_back_key_guide, Toast.LENGTH_SHORT).show();
            mNeedShowBackKeyGuide = false;
        }
        return true;
    }
    return handled;
}