I get a null pointer exception at this row:
public void hideKeyboard(){
InputMethodManager inputManager = (InputMethodManager)
this.
I had the same issue where getCurrentFocus() was returning null. So this method worked for me, and I would just call it on my onClick to hide the keyboard if its shown or still not throw a null pointer exception even if the keyboard was not shown:
public void hiddenInputMethod() {
InputMethodManager imm = (InputMethodManager) getSystemService(MyActivity.this.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null)
imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}