0

Keyboard is not getting hidden while my app is moving in background in Marshmallow and some android OS. Here's my code

InputMethodManager imm = (InputMethodManager)
                getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromInputMethod(getWindow().getCurrentFocus()
                .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

1 Answers1

0

try this

if(getCurrentFocus() != null) {
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
br00
  • 1,391
  • 11
  • 21