androidandroid-softkeyboardandroid-input-methodandroid-hardware-keyboard

Android soft input behavior for KEYBOARD_12KEY, KEYBOARD_QWERTY, and KEYBOARD_NOKEYS


I was wondering if anybody here knows in what scenarios will Android show the user an on-screen soft keyboard, and how Android takes into account the different types of hardware keyboards available (KEYBOARD_12KEY, KEYBOARD_QWERTY, and KEYBOARD_NOKEYS).

https://developer.android.com/reference/android/content/res/Configuration#keyboard

Question (PART 1) - Could someone please fill out the following

Note that ??? = [show | hide | do nothing | other]

Scenario 1)
User clicks on a AppCompatEditText and has KEYBOARD_NOKEYS, Android will ??? soft input

Scenario 2)
User clicks on a AppCompatEditText and has KEYBOARD_12KEY, Android will ??? soft input

Scenario 3)
User clicks on a AppCompatEditText and has KEYBOARD_QWERTY, Android will ??? soft input

Question (PART 2) - Is it possible to disable this built-in behavior

Now that you have filled in all the blanks of ??? = [show | hide | do nothing | other], is it possible to disable these built-in Android behaviors? And instead replace them all with custom versions by manually detecting the hardware keyboard type on the device and showing/hiding the soft keyboard inside a View.OnFocusChangeListener?


Solution

  • Whether to display the soft keyboard is actually decided by the soft keyboard. The soft keyboard has a function InputMethodService.onEvaluateInputViewShown(). This function is called when there's a chance to show the soft keyboard. If it returns true, the keyboard will be shown. The default implementation is to look and see if a hardware keyboard exists, and to not display if so. But the soft keyboard can override that to display anyway.

    All of this is totally up to the soft keyboard app- whichever keyboard they're using (so behavior can change based on which keyboard the user prefers). There's no way for anything else to override it.