I get a null pointer exception at this row:
public void hideKeyboard(){
InputMethodManager inputManager = (InputMethodManager)
this.
The main problem is in
getCurrentFocus().getWindowToken()
Here getcurrentFocus() is the issue. This problem can be solved easily through providing a valid view residing on your current screen like
yourButtonOnScreen.getWindowToken()
That button wo'nt be null as that is showing on your screen so it will resolve the issue.
Still if you do'nt have any valid view on your screen the just replace
getCurrentFocus().getWindowToken()...
with
//in case of fragment
new View(getActivity()).getWindowToken()
//in case of activity
new View(this).getWindowToken()
hope this will resolve the issue..good luck!