Search code examples
androidandroid-layoutandroid-keypad

How to mimic Google Keyboard's spacebar long-press functionality for switching keyboards?


Google Keyboard lets you long-press the spacebar to switch keyboards in Android. I haven't turned anything up with a Google search but I'm certain there's a way to do this programmatically.

How can I bring up the input method picker?


Solution

  • They use showInputMethodPicker():

    private void onSpaceBarLongPress() {
        InputMethodManager imm = (InputMethodManager)
            getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showInputMethodPicker();
    }