title: How to dismiss a dialog from another method
body: <p>I have created a dialog which can be called from anywhere by supplying a title and message as follows:</p>
  
  <pre><code>public void alertbox(String title, String mymessage)
  {   new AlertDialog.Builder(this)
          .setTitle(title)
          .setMessage(mymessage)
          .setNeutralButton(android.R.string.cancel,
                  new DialogInterface.OnClickListener() 
                  {   public void onClick(DialogInterface dialog, int whichButton) {}
                  })
          .show();
  }
  </code></pre>
  
  <p>But I get a lockup when I try to dismiss the dialog from another method:</p>
  
  <pre><code>private void doCheck() {
      alertbox("status", getString(R.string.checking_license));
      mChecker.checkAccess(mLicenseCheckerCallback);
  
      alertbox.dismiss();
  } 
  </code></pre>
  
  <p>It is the alertbox.dismiss(); statement that causes the crash. Any ideas how to properly do this?</p>