android - Keyboard is not getting hidden while my app is moving in background in Marshmallow -


keyboard not getting hidden while app moving in background in marshmallow , android os. here's code

inputmethodmanager imm = (inputmethodmanager)                 getsystemservice(context.input_method_service);         imm.hidesoftinputfrominputmethod(getwindow().getcurrentfocus()                 .getwindowtoken(), inputmethodmanager.hide_not_always); 

try this

if(getcurrentfocus() != null) {     inputmethodmanager inputmethodmanager = (inputmethodmanager) getsystemservice(input_method_service);     inputmethodmanager.hidesoftinputfromwindow(getcurrentfocus().getwindowtoken(), 0); } 

Comments