I have a Fragment that contains an Edit Text. When the Edit Text is pressed, the keyboard is being shown. When pressed the Save button in the upper corner, the application retur
public void hideKeyboard(Activity activity) {
InputMethodManager inputManager = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
// check if no view has focus:
View currentFocusedView = activity.getCurrentFocus();
if (currentFocusedView != null) {
inputManager.hideSoftInputFromWindow(currentFocusedView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}