I’m facing some problems with the progress dialogs. I use a managed progress dialog to show the user that an operation is being carried out with the following code written in the onCreateDialog(int id) function:
case PROGRESS_DIALOG :
{
dialog = new ProgressDialog(this);
dialog.setMessage(getResources().getString(R.string.eStrUpdating));
dialog.setCancelable(true);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialogInterface)
{
Log.i(TAG,"progress dialog cancelled ");
}
});
return dialog;
}
When the operation completes I call dismissDialog(PROGRESS_DIALOG). The problem is that if I rotate the phone while the progress dialog is displayed then when the operation completes the dismiss call has no effect and the progress remains showing. And this I cannot understand why.
When you rotate the phone, the Activity is destroy and recreated. Then you should call dismiss on your dialog, in the onDestroy method of your activity and recreate it.