title: Android - Show alert dialog in AsyncTask
body: <p>I'm trying to show an alert dialog when a user fails to enter valid email and password to log in. Since the login process has to deal with HTTP request and JSON, I put it all in an AsyncTask and I'm not sure if that's the problem why my alert dialog can't show (I hope not). So this is method <code>checkUser</code>, which is called within <code>onPostExecute</code> of the <code>AsyncTask</code> class:</p>
  
  <pre><code>    public void checkUser(JSONObject json){
                  AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                  if (tag == login_tag){
                      // check for login response
                      try {
                          if (json.getString(KEY_SUCCESS) != null) {
                              String res = json.getString(KEY_SUCCESS);
                              if(Integer.parseInt(res) == 1){
                                  // user successfully logged in
                                  // Store user details in SQLite Database
                                  // code omitted
                              } else{
                                  // Error in login
                                      mProgressDialog.dismiss();
                                  builder.setMessage("Incorrect username/password")
                                         .setTitle("Error")
                                         .setNeutralButton("OK", new OnClickListener() {
                                             public void onClick(final DialogInterface dialog,final int which) {
                                                  dialog.cancel();                                                    
                                             }
                                          }).create().show();
  
                              }
                          }
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
  </code></pre>
  
  <p>Somehow my alert dialog can never show and I don't know why. If you have any idea what the reason of this problem is, please help me out. Thanks a lot!</p>
  
  <p>EDIT: Turns out I only close my <code>Progress Dialog</code> after executing this method, so I decided to dismiss it before showing the alert dialog. But it still hasn't solved the problem.</p>