title: Using AsyncTask to start activity
body: <p>I am using asyncTask to show Dialog and then after few minutes then launch a new activity.</p>
  
  <p>unfortunately that activity start before task finished ???</p>
  
  <pre><code>package com.android.grad;
  
  import android.app.Activity;
  
  import android.app.ProgressDialog;
  
  import android.os.AsyncTask;
  
  import android.widget.Toast;
  
  public class LoginTask extends AsyncTask&lt;Void, Void, Boolean&gt; {
  private Activity activity;
  private ProgressDialog pd;
  
  public LoginTask(Activity activity) {
      this.activity = activity;
  }
  
  @Override
  protected void onPreExecute() {
      pd = ProgressDialog.show(activity, "Signing in",
              "Please wait while we are signing you in..");
  }
  
  @Override
  protected Boolean doInBackground(Void... arg0) {
      try {
          Thread.sleep(10000000);
      } catch (InterruptedException e) {
      }
      pd.dismiss();
      return true;
  }
  
  @Override
  protected void onPostExecute(Boolean result) {
      Toast.makeText(activity, Boolean.toString(result), Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and i execute the task from button click listener :S</p>
  
  <pre><code>private OnClickListener loginOnClick = new OnClickListener() {
  
          public void onClick(View v) {
              new LoginTask(LoginActivity.this).execute();
              startActivity(new Intent(LoginActivity.this, BuiltInCamera.class));
          }
      };
  </code></pre>
  
  <p>Is there way to startActivity from my subClass ofAsyncTask .</p>