1

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?

Andrii Tsarenko
  • 655
  • 7
  • 21

3 Answers3

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

https://stackoverflow.com/a/4737265/6637804

Community
  • 1
  • 1
rob.Steel
  • 61
  • 1
  • 6
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