I tried the same, still sometime keyboard is visible sometime not, so I mentioned driver.hidekeyboard() in a try catch() block, but sometime driver.hidekeyboard is unable to hide the visible keyboard. Please let me know how can I find out the keyboard element so that I can resolve the issue.
or
I want to try the below approach :
if keyboard element is found then will press device back button,
In my opinion above approach would be best to resolve hidekeyboard() issue.