I just dont bother too see if its open or not
public static void hideKeyboard(AppiumDriver driver) throws Exception {
try {
driver.hideKeyboard();
} catch (Exception e) {
//Lets ignore, apparently its throwing exception when keyboard was not opened
}
}
But if you really need it, check @auto-geek answer in here (I tried it and it works perfectly):