Example usage for android.view KeyEvent KEYCODE_NUMPAD_3

List of usage examples for android.view KeyEvent KEYCODE_NUMPAD_3

Introduction

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

Prototype

int KEYCODE_NUMPAD_3

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

Click Source Link

Document

Key code constant: Numeric keypad '3' key.

Usage

From source file:org.deviceconnect.android.deviceplugin.host.activity.KeyEventProfileActivity.java

@Override
public boolean onTouch(final View v, final MotionEvent event) {
    int action = event.getAction();

    // Emulate ten key down/up event.
    switch (action) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_UP:
        KeyEvent keyevent = null;
        int i = v.getId();
        if (i == R.id.button_0) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_0);
        } else if (i == R.id.button_1) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_1);
        } else if (i == R.id.button_2) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_2);
        } else if (i == R.id.button_3) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_3);
        } else if (i == R.id.button_4) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_4);
        } else if (i == R.id.button_5) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_5);
        } else if (i == R.id.button_6) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_6);
        } else if (i == R.id.button_7) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_7);
        } else if (i == R.id.button_8) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_8);
        } else if (i == R.id.button_9) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_9);
        } else if (i == R.id.button_dot) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_DOT);
        } else if (i == R.id.button_enter) {
            keyevent = new KeyEvent(action, KeyEvent.KEYCODE_NUMPAD_ENTER);
        } else if (i == R.id.button_keyevent_close) {
            finish();/*from   ww  w  .  j a  v a  2  s.c  om*/
        }
        if (keyevent != null) {
            dispatchKeyEvent(keyevent);
        }
        break;
    default:
        break;
    }

    return false;
}

From source file:org.deviceconnect.android.deviceplugin.host.activity.KeyEventProfileActivity.java

/**
 * Get Configure string./*from   w  w  w .  ja  v  a  2  s  . c  o  m*/
 * 
 * @param keymode Key Mode.
 * @param keyId Key ID.
 * @return config Configure string.
 */
private String getConfig(final KeyMode keymode, final int keyId) {
    String config = "";
    int nIndex = -1;
    switch (keyId) {
    case KeyEvent.KEYCODE_NUMPAD_0:
        nIndex = 0;
        break;
    case KeyEvent.KEYCODE_NUMPAD_1:
        nIndex = 1;
        break;
    case KeyEvent.KEYCODE_NUMPAD_2:
        nIndex = 2;
        break;
    case KeyEvent.KEYCODE_NUMPAD_3:
        nIndex = 3;
        break;
    case KeyEvent.KEYCODE_NUMPAD_4:
        nIndex = 4;
        break;
    case KeyEvent.KEYCODE_NUMPAD_5:
        nIndex = 5;
        break;
    case KeyEvent.KEYCODE_NUMPAD_6:
        nIndex = 6;
        break;
    case KeyEvent.KEYCODE_NUMPAD_7:
        nIndex = 7;
        break;
    case KeyEvent.KEYCODE_NUMPAD_8:
        nIndex = 8;
        break;
    case KeyEvent.KEYCODE_NUMPAD_9:
        nIndex = 9;
        break;
    case KeyEvent.KEYCODE_NUMPAD_DOT:
        nIndex = 10;
        break;
    case KeyEvent.KEYCODE_NUMPAD_ENTER:
        nIndex = 11;
        break;
    default:
        nIndex = -1;
        break;
    }
    if (nIndex != -1) {
        switch (mKeyMode) {
        case MEDIA_CTRL:
            config = mConfigMediaCtrl[nIndex];
            break;
        case DPAD_BUTTON:
            config = mConfigDpad[nIndex];
            break;
        case USER:
            config = mConfigUser[nIndex];
            break;
        case STD_KEY:
        default:
            config = mConfigStdKey[nIndex];
            break;
        }
    } else {
        config = "";
    }

    return config;
}