Example usage for android.view KeyEvent KEYCODE_PAIRING

List of usage examples for android.view KeyEvent KEYCODE_PAIRING

Introduction

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

Prototype

int KEYCODE_PAIRING

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

Click Source Link

Document

Key code constant: Pairing key.

Usage

From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java

@Override
public void onNewIntent(Intent intent) {
    if (ACTION_CONNECT_INPUT.equals(intent.getAction())
            && (intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) == 0) {
        // We were the front most app and we got a new intent.
        // If screen saver is going, stop it.
        try {/*ww w  . j a v a  2  s.c  o  m*/
            if (mDreamManager != null && mDreamManager.isDreaming()) {
                mDreamManager.awaken();
            }
        } catch (RemoteException e) {
            // Do nothing.
        }

        KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
        if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_PAIRING) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                onHwKeyEvent(false);
            } else if (event.getAction() == KeyEvent.ACTION_DOWN) {
                onHwKeyEvent(true);
            }
        }
    } else {
        setIntent(intent);
    }
}