Skip to content

Instantly share code, notes, and snippets.

@alidaoud
Created March 17, 2020 02:24
Show Gist options
  • Select an option

  • Save alidaoud/6c4c55d3aea20fbc614cbcbdebfe5d00 to your computer and use it in GitHub Desktop.

Select an option

Save alidaoud/6c4c55d3aea20fbc614cbcbdebfe5d00 to your computer and use it in GitHub Desktop.
private static void hideKeyboard(Activity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view == null) {
view = new View(activity);
}
if (inputMethodManager != null){
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment