title: Showing Progress Dialog in AsyncTask
body: <p>Hello There I have to show an Progress Dialog in my async task, my async task is:</p>
  
  <pre><code>  private class UserProfileDialog extends AsyncTask&lt;String, String, String&gt; {
  
      private String imagePath;
      private String name;
      private String status;
      private String number;
      private Activity activity;
      private ProgressDialog progressDialog;
  
      public UserProfileDialog(Activity activity) {
          this.activity = activity;
      }
  
      @Override
      protected void onPreExecute() {
          progressDialog = new ProgressDialog(activity);
          progressDialog.setMessage("Please Wait...");
          progressDialog.setCancelable(false);
          progressDialog.show();
          super.onPreExecute();
      }
  
      @Override
      protected String doInBackground(String... params) {
          imagePath = params[0];
          name = params[1];
          status = params[2];
          number = params[3];
          activity.runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  try {
                      //show the dialog for dob date picker
                      final Dialog profileDialog = new Dialog(context);
                      profileDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                      profileDialog.setContentView(R.layout.profile_dialog_me);
  
                      TextView title = (TextView) profileDialog.findViewById(R.id.title);
                      title.setTypeface(EasyFonts.robotoBold(context));
  
                      ImageView imageCloser = (ImageView) profileDialog.findViewById(R.id.imageCloser);
                      final ImageView profilePicture_x = (ImageView) profileDialog.findViewById(R.id.profilePicture);
  
                      //set the profile picture
                      Bitmap originalBitmap = BitmapFactory.decodeFile(new File(imagePath).getAbsolutePath());
                      originalBitmap = ModifyOrientationUtility.modifyOrientation(originalBitmap, new File(imagePath).getAbsolutePath());
                      Bitmap bitmap = resizeBitmapFitXY(400, 400, originalBitmap);
                      ByteArrayOutputStream stream = new ByteArrayOutputStream();
                      bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
                      Glide.with(context)
                              .load(stream.toByteArray())
                              .asBitmap()
                              .diskCacheStrategy(DiskCacheStrategy.NONE)
                              .skipMemoryCache(true)
                              .dontAnimate()
                              .into(new SimpleTarget&lt;Bitmap&gt;() {
  
                                  @Override
                                  public void onResourceReady(Bitmap arg0, GlideAnimation&lt;? super Bitmap&gt; arg1) {
                                      // TODO Auto-generated method stub
                                      profilePicture_x.setImageBitmap(arg0);
                                  }
                              });
  
                      TextView profileName = (TextView) profileDialog.findViewById(R.id.profileName);
                      profileName.setTypeface(EasyFonts.robotoLight(context));
                      profileName.setText(name);
  
                      TextView profileNumber = (TextView) profileDialog.findViewById(R.id.profileNumber);
                      profileNumber.setTypeface(EasyFonts.robotoLight(context));
                      profileNumber.setText(number);
  
                      TextView profileStatus = (TextView) profileDialog.findViewById(R.id.profileStatus);
                      profileStatus.setTypeface(EasyFonts.robotoLight(context));
                      profileStatus.setText(status);
                      //UI Events
                      imageCloser.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              profileDialog.dismiss();
                          }
                      });
                      //show the dialog
                      profileDialog.show();
                  } catch (Exception exp) {
                      MyMLogger.showMLog("xm", "show profile dialog " + exp.toString(), logFromClass, "showProfileDialog");
                      exp.printStackTrace();
                  }
              }
          });
          return null;
      }
  
      @Override
      protected void onPostExecute(String s) {
          if (progressDialog.isShowing()) {
              progressDialog.dismiss();
          }
          super.onPostExecute(s);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>The AsyncTask is working find but it do not shows me the progress dialog when I start my task on the button click!</p>
  
  <p>But whenever I Dismiss the profile dialog it starts showing me the progress dialog (ignoring the onPostExecute).</p>
  
  <p>Can somebody please figure the problem out, I am bit confusing why it is happening!</p>