Example usage for android.view KeyEvent getMatch

List of usage examples for android.view KeyEvent getMatch

Introduction

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

Prototype

public char getMatch(char[] chars) 

Source Link

Document

Gets the first character in the character array that can be generated by the specified key code.

Usage

From source file:Main.java

/**
 * Get an unaccepted key code.//from ww w .  j av  a 2s .c o m
 *
 * @param acceptedChars accepted chars array.
 * @return return key code if we find unaccepted one, or return -1.
 */
public static int getUnacceptedKeyCode(char[] acceptedChars) {
    for (int keyCode = KeyEvent.KEYCODE_A; keyCode <= KeyEvent.KEYCODE_Z; keyCode++) {
        KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
        if ('\0' == event.getMatch(acceptedChars)) {
            return keyCode;
        }
    }
    return -1;
}