I am seeing that a ProgressDialog is persisting after a screen
rotation, even though I am calling dismissDialog in the onPause
method. I do know that a new Activity is created after the screen
rotation and I have read threads like
http://groups.google.com/group/android-developers/browse_thread/thread/bf046b95cf38832d/1c3bd1f1c0b72569?lnk=gst&q=dismissDialog+orientation#1c3bd1f1c0b72569.
However, my scenario is simpler in that there is no background task
which holds onto the old Activity. Any ideas?

Thanks
Shri


package com.shri.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.app.ProgressDialog;
import android.app.Dialog;
import android.view.View;

public class MainActivity extends Activity {
  private static final int DIALOG_LOADING_DOCUMENT = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

  @Override
  public void onPause() {
    // dismissDialog(DIALOG_LOADING_DOCUMENT);
    super.onPause();
    dismissDialog(DIALOG_LOADING_DOCUMENT);
  }

  //
  // Click the button to start the ProgressDialog, and then rotate the
screen. I expect the dialog to be
  // dismissed as onPause gets called when the current Activity is
being destroyed, and it calls dismissDialog.
  // However, I see that the dialog persists after the screen
rotation.
  //
  public void onClick(View view) {
    showDialog(DIALOG_LOADING_DOCUMENT);
  }

  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_LOADING_DOCUMENT: {
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage("Loading document...");
        return progressDialog;
      }
      default:
        return super.onCreateDialog(id);
    }
  }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to