Progress dialog in async task is not shown anymore after screen rotation
<p>I am using an async task for uploading pictures to a remote server. To show the progress to the user I am using a progress dialog. This progress dialog is created at the preExecute method of the async task class.</p>

<p>When the user rotates the screen, the progress dialog disappears but the async task is still running. The activity holds a static reference to the async task so I do know that the task is still running. How can I now show up the progress dialog again? I tried the following:</p>

<p>The create method of the activity:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);

if(task != null) {
Status status = task.getStatus();

if(status == Status.RUNNING) {
    task.updateViewContext(this);
}

}
</code></pre>

<p>the constructor of my async task class:</p>

<pre><code>public UploadTask(UploadPicturesActivity activity) {
   this.context = activity;
   dialog = new ProgressDialog(activity);
   dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);        
}   
</code></pre>

<p>the preexcetue method of my asnyc task class:</p>

<pre><code>protected void onPreExecute() {
     this.dialog.show();
}
</code></pre>

<p>and trying to show the dialog again (does not work):</p>

<pre><code>public void updateViewContext(UploadPicturesActivity activity) {
    this.context = activity;
    dialog.show();
}
</code></pre>

<p>Regards</p>

<p>Michael</p>
