I have some code:
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0, new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
keyboardClosed();
}
});
However, running this on a 4.3 emulator the onReceiveResult()
method is never called.
I'm sure I'm doing something wrong, but can't see what...
Can anyone provide me with either some details of how to do this properly or why it isn't working?
ResultReceiver
is not called if hideSoftInputFromWindow
returns false
.
You can check this value:
boolean hide = inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0, new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
keyboardClosed();
}
});
if (!hide) {
// already hidden
keyboardClosed();
}