How to check visibility of software keyboard in Android?

前端 未结 30 4414
半阙折子戏
半阙折子戏 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:24

    you can try this, work great for me:

    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    
    if (imm.isAcceptingText()) {
        //Software Keyboard was shown..
    } else {
        //Software Keyboard was not shown..
    }
    

提交回复
热议问题