public static void hideKeyboard ( Context context ) { try { InputMethodManager imm = ( InputMethodManager ) context . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; View currentFocus = ( ( Activity ) context ) . getCurrentFocus ( ) ; if ( imm != null && currentFocus != null ) { IBinder windowToken = currentFocus . getWindowToken ( ) ; if ( windowToken != null ) { imm . hideSoftInputFromWindow ( windowToken , 0 ) ; } } } catch ( Exception e ) { Log . e ( LOG_TAG , "Can't even hide keyboard " + e . getMessage ( ) ) ; } }
Hides the already popped up keyboard from the screen .