How to check visibility of software keyboard in Android?

前端 未结 30 4415
半阙折子戏
半阙折子戏 2020-11-21 04:43

I need to do a very simple thing - find out if the software keyboard is shown. Is this possible in Android?

30条回答
  •  走了就别回头了
    2020-11-21 05:21

    i think this method will help you to find out is keybord is visible or not.

     public Boolean isSoftKeyBoardVisible(){
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    
        if (imm.isAcceptingText()) {
            Log.d(TAG,"Software Keyboard was shown");
            return true;
        } else {
            Log.d(TAG,"Software Keyboard was not shown");
            return false;
        }
    
    }
    

提交回复
热议问题