I'm wondering how best to hide the on-screen (soft?) keyboard after the user pushes a button. They keyboard will likely still be visible as the user is entering text before submitting it, I'd like to shrink the window on their submission.
I have found answers to the question here and here but neither seem to properly work. They keyboard is still visible, though Toast notifications are displayed on top.
My code, for clarity:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromInputMethod(getCurrentFocus().getWindowToken(), 0);
And I have also tried:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromInputMethod(((EditText)findViewById(R.id.txtToWrite)).getWindowToken(), InputMethodManager.0);