/** * Gets the fallback action to perform if the application does not handle the specified key. * * <p>When an application does not handle a particular key, the system may translate the key to an * alternate fallback key (specified in the fallback action) and dispatch it to the application. * The event containing the fallback key is flagged with {@link KeyEvent#FLAG_FALLBACK}. * * @param keyCode The key code. * @param metaState The meta key modifier state. * @param outFallbackAction The fallback action object to populate. * @return True if a fallback action was found, false otherwise. * @hide */ public boolean getFallbackAction(int keyCode, int metaState, FallbackAction outFallbackAction) { if (outFallbackAction == null) { throw new IllegalArgumentException("fallbackAction must not be null"); } metaState = KeyEvent.normalizeMetaState(metaState); return nativeGetFallbackAction(mPtr, keyCode, metaState, outFallbackAction); }
/** * Gets the first character in the character array that can be generated by the specified key * code. If there are multiple choices, prefers the one that would be generated with the specified * meta key modifier state. * * @param keyCode The key code. * @param chars The array of matching characters to consider. * @param metaState The preferred meta key modifier state. * @return The matching associated character, or 0 if none. */ public char getMatch(int keyCode, char[] chars, int metaState) { if (chars == null) { throw new IllegalArgumentException("chars must not be null."); } metaState = KeyEvent.normalizeMetaState(metaState); return nativeGetMatch(mPtr, keyCode, chars, metaState); }
/** * Gets the Unicode character generated by the specified key and meta key state combination. * * <p>Returns the Unicode character that the specified key would produce when the specified meta * bits (see {@link MetaKeyKeyListener}) were active. * * <p>Returns 0 if the key is not one that is used to type Unicode characters. * * <p>If the return value has bit {@link #COMBINING_ACCENT} set, the key is a "dead key" that * should be combined with another to actually produce a character -- see {@link #getDeadChar} -- * after masking with {@link #COMBINING_ACCENT_MASK}. * * @param keyCode The key code. * @param metaState The meta key modifier state. * @return The associated character or combining accent, or 0 if none. */ public int get(int keyCode, int metaState) { metaState = KeyEvent.normalizeMetaState(metaState); char ch = nativeGetCharacter(mPtr, keyCode, metaState); int map = COMBINING.get(ch); if (map != 0) { return map; } else { return ch; } }