public static void hideKeyboard ( Activity act ) { if ( act != null && act . getCurrentFocus ( ) != null ) { InputMethodManager inputMethodManager = ( InputMethodManager ) act . getSystemService ( Activity . INPUT_METHOD_SERVICE ) ; inputMethodManager . hideSoftInputFromWindow ( act . getCurrentFocus ( ) . getWindowToken ( ) , 0 ) ; } }
Helper to hide the keyboard