title: Progress Dialog Freezes while switching to another activity
body: <p>I have two activities. While switching to second activity by intent, it takes 3-4 seconds because it has lots of components with adapters fetching data from SQLite etc. Thus, I want to show a progress dialog while switching.</p>
  
  <p>I have been digging topics for this purpose and tried many of them:</p>
  
  <p>1-) Using AsyncTask on the second activity. It doesn't show the progress dialog as soon as I click on a component to switch to the second activity. It waits for 3-4 seconds and then progress dialog shows up for less then a second which is not user-friendly way.</p>
  
  <p>2-) Using AsyncTask on the first activity. It shows as soon as I click on that component but the progress wheel doesn't spin. The progress dialog freezes.</p>
  
  <p>3-) Using AsyncTask onStart() method on the second activity. This results as the first way.</p>
  
  <p>The code below implements the second way above, using AsyncTask on the first activity.</p>
  
  <pre><code>public void toVisitRegister(Event event) { //Switching to the second activity
      new startingThread().execute();
      Intent toVisitRegister = new Intent(MainCalendar.this, VisitRegister.class);
      startActivity(toVisitRegister);
      finish();
  }
  </code></pre>
  
  <p>And here is the AsyncTask</p>
  
  <pre><code>public class startingThread extends AsyncTask&lt;String, String, String&gt; { 
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          startingProgress = new ProgressDialog(MainCalendar.this);
          startingProgress.setTitle("Visit Register");
          startingProgress.setMessage("Initializing...");
          startingProgress.show();
          }
  
      @Override
      protected String doInBackground(String... params) {
          return null;
      }
  
      @Override
      protected void onPostExecute(String result) {
          super.onPostExecute(result);
          if(MainCalendar.this.startingProgress != null) {
              MainCalendar.this.startingProgress.dismiss();
          }
      }
  }
  </code></pre>
  
  <p>I also tried to call startActivity in onPostExecute, but it didn't work. Therefore, I am waiting for your opinions and suggessions about this issue. Any help will be appreciated.</p>
  
  <p>Thanks.</p>