With android's recent emphasis on using DialogFragment container you wil not need to call dismiss on each
Since the dialogs will have a Fragment container you may simply use their lifecycle. Consider this DialogFragment:
public class FragDialog extends DialogFragment{
public ProgressDialog _dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
//this.dismiss(); <-- The dialogs may be dismissed here
}
}
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
_dialog = new ProgressDialog(getActivity());
return _dialog;
}
@Override
public void onPause() {
super.onPause();
// <--------- You may overload onPause
}
}
Which you will show in your activity using a fragmentmanager normally calling it like this:
FragmentManager fm = getSupportFragmentManager();
FragDialog fragDialog = new FragDialog();
fragDialog.show(fm, "my_tag");
Note that you may actually alter what the DialogFragment does in onPause. When your activity calls onPause, this onPause will be called too.
Dismissing the dialog in onPause() using this.dismiss() won't do the work because once the activity resumes it will resume the dialog as well. (I think this is because the savestate is stored prior to onPause).
But you can safely dismiss the dialog(s) in onCreate if you detect a savedInstanceState (a resume) like shown in the code.