Skip to content

Instantly share code, notes, and snippets.

@hrules6872
Created December 21, 2015 14:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrules6872/5fcac5c5da8a017fc53e to your computer and use it in GitHub Desktop.
Save hrules6872/5fcac5c5da8a017fc53e to your computer and use it in GitHub Desktop.
Hide SoftKeyboard
public void hideSoftKeyboard(Activity context) {
View view = context.getCurrentFocus();
if (view == null) {
return;
}
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
view.clearFocus();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment