title: My Dialog.show() not work
body: <p>I am making a loading effect when calling MainActivity. I have no idea why my Dialog.show is not working in the AsyncTask. All i just see the just the instant when it dismiss, but the dialog never appear before that. 
  Thank you.</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      new LoadViewTask().execute(); 
      setContentView(R.layout.activity_main);
  ....}
  
  
  
  private class LoadViewTask extends AsyncTask&lt;Void, Integer, Void&gt;
  {
      @Override
      protected void onPreExecute() { 
          progressDialog = ProgressDialog.show(MainActivity.this,"Loading...","Loading application View, please wait...", false, false);  
  
      }
  
      @Override
      protected Void doInBackground(Void... params) 
      {
          try 
          {
              synchronized (this) 
              {
                  int counter = 0;
                  while(counter &lt;= 4)
                  {
                      this.wait(1000);
                                              counter++;
                      publishProgress(counter*25);
                  }
              }
          } 
          catch (InterruptedException e) 
          {
              e.printStackTrace();
          }
          return null;
      }
  
      @Override
      protected void onProgressUpdate(Integer... values) 
      {
          progressDialog.setProgress(values[0]);
      }
  
      @Override
      protected void onPostExecute(Void result) 
      {
          progressDialog.dismiss();
      }
  
  
  }
  </code></pre>