Hide Keyboard

Request to hide the soft input window from the context of the window that is currently accepting input. This should be called as a result of the user doing some actually than fairly explicitly requests to have the input window hidden.

/**
* This method hides the soft input window, if it's open.
*
* @param activity Activity to hide soft input window
*/
public static void hideKeyboard(Activity activity) {
    if (activity != null && activity.getCurrentFocus() != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }
}

Source: https://www.reddit.com/r/androiddev/wiki/utilities