title: How to dismiss android keyboard on dialog dismiss?
body: <p>I have a dialog box open in my android app, and I have a button when clicked will dismiss the dialog box. The problem is there is also a textedit field, and if its focused and the keyboard is showing, then when I click the cancel button, then dialog goes away, but the keyboard is still showing.</p>
  
  <p>I want to also dismiss the keyboard.</p>
  
  <p>I was searching around, and for threads like this
  <a href="https://stackoverflow.com/questions/11633792/hide-soft-keyboard-after-dialog-dismiss">Hide soft keyboard after dialog dismiss</a></p>
  
  <p>But none of the solutions worked for me. By the way the edittext is a number input type, if that makes a difference somehow.</p>
  
  <p>Does anyone know how to fix this?</p>
  
  <p>Thanks</p>
  
  <pre><code>public void HandleTeamManagement() {
      final Dialog teamDialog = new Dialog(this);
      teamDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
      teamDialog.setContentView(R.layout.dialog_team_management);
  
      final EditText mergeNum = (EditText) teamDialog.findViewById(R.id.group);
  
  
      InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(mergeNum.getWindowToken(), 0);
  
  
  
      // Setting Negative "NO" Button
      Button cancelButton = (Button) teamDialog.findViewById(R.id.cancel);
      cancelButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              teamDialog.dismiss();
          }
      });
  
      // Showing Alert Dialog
      teamDialog.show();
  }
  </code></pre>