1 private void closeSoftKeyboard()
2 {
3 //If using a fragment use getActivity().getCurrentFocus()
4 View v = this.getCurrentFocus();
5
6 // If Soft Keyboard is visible, it will be hide
7 if (v != null) {
8 //If using a fragment use getActivity().getSystemService(...)
9 InputMethodManager inputManager
10 = (InputMethodManager)
11 getSystemService(Context.INPUT_METHOD_SERVICE);
12 inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
13 }
14 }