Skip to content

Instantly share code, notes, and snippets.

@evant
Created February 5, 2016 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evant/13b818367f62e1e68081 to your computer and use it in GitHub Desktop.
Save evant/13b818367f62e1e68081 to your computer and use it in GitHub Desktop.
public static void hideKeyboard(Activity context) {
View currentFocus = context.getCurrentFocus();
if (currentFocus != null) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment