androidsoft-keyboardinputconnection

Android soft keyboard: only top row of keys work


This question already has an answer, it's a contibution to SO question base.

In my custom view I implemented the onCreateInputConnection method like so:

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    BaseInputConnection baseInputConnection =
            new BaseInputConnection(this, false);

    outAttrs.actionLabel = null;
    outAttrs.inputType = InputType.TYPE_NULL;
    outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;

    return baseInputConnection;
}

But for some strange reason, in default AOSP keyboard in Android 5 only top row of keys work. Note that I have a landscape layout. If I switch to portrait, it starts to work properly. Other keyboards also work right.


Solution

  • As it turns out, I had to change this line:

    outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    

    IME_FLAG_NO_EXTRACT_UI is a flag to prevent keyboard from going to fullscreen. But it doesn't go to fullscreen already (as my input type is TYPE_NULL).

    Bottom line, it's a bug with Android 5.