Android Show Soft Keyboard When First Activity Starts?

前端 未结 3 1881
遥遥无期
遥遥无期 2020-12-29 16:47

I need to display the virtual keyboard when the application starts, but so far I\'ve failed.

I use this code in method \"OnCreate\"to display the virtual keyboard

3条回答
  •  粉色の甜心
    2020-12-29 17:10

    I faced with the same issue, this method below helped me

    public static void showKeyboard(Context context) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
        }
    }
    

提交回复
热议问题