code: public static void closeKeyboard(Context context, View field) {
          try {
              InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(field.getWindowToken(), 0);
          } catch (Exception ex) {
              Log.e("Caffeine", "Error occurred trying to hide the keyboard.  Exception=" + ex);
          }
      }
docs: Go away keyboard, nobody likes you.
  
  @param context The current Context or Activity that this method is called from.
  @param field   field that holds the keyboard focus.