In my mobile application, I have to know when soft keyboard is opened and closed.
I manage to do it by listening onFocus and onBlur events on input node.
Everything is fine untill keyboard is closed via 'backbutton' (tested on Samsung galaxy s6). When back button is pressed keyboard is closed but input element still in focus.
Does anybody know how to cope with this problem?
Asked
Active
Viewed 1,346 times
1

Andrii Tsarenko
- 655
- 7
- 21
-
listening of onResize event it's not option for me – Andrii Tsarenko Jul 27 '16 at 14:26
3 Answers
0
You can't. THere isn't even a way to do this in a native app reliably. Its just not part of the API

Gabe Sechan
- 90,003
- 9
- 87
- 127
0
There are other ways to do this but not from an Event (Native Way)
Here is a workaround
0
Here is one way to check if the soft keyboard is closed, while the input element still has focus:
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
if(!imm.isAcceptingText())
{
//clear focus...
edittext.clearFocus();
}
By clearing focus with "clearFocus()" method.

Nikhil
- 312
- 2
- 13