diff --git a/src/com/android/settings/notification/modes/ZenModeScheduleChooserDialog.java b/src/com/android/settings/notification/modes/ZenModeScheduleChooserDialog.java index d129aad6ad6..370199a6292 100644 --- a/src/com/android/settings/notification/modes/ZenModeScheduleChooserDialog.java +++ b/src/com/android/settings/notification/modes/ZenModeScheduleChooserDialog.java @@ -81,6 +81,17 @@ public class ZenModeScheduleChooserDialog extends InstrumentedDialogFragment { dialog.show(parent.getParentFragmentManager(), TAG); } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (mOptionListener == null) { + // Probably the dialog fragment was recreated after its activity being destroyed. + // It's pointless to re-show the dialog if we can't do anything when its options are + // selected, so we don't. + dismiss(); + } + } + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { diff --git a/src/com/android/settings/notification/modes/ZenModesListAddModeTypeChooserDialog.java b/src/com/android/settings/notification/modes/ZenModesListAddModeTypeChooserDialog.java index e7905a8f936..0bf9c5bd472 100644 --- a/src/com/android/settings/notification/modes/ZenModesListAddModeTypeChooserDialog.java +++ b/src/com/android/settings/notification/modes/ZenModesListAddModeTypeChooserDialog.java @@ -70,6 +70,17 @@ public class ZenModesListAddModeTypeChooserDialog extends InstrumentedDialogFrag dialog.show(parent.getParentFragmentManager(), TAG); } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (mChooseModeTypeListener == null) { + // Probably the dialog fragment was recreated after its activity being destroyed. + // It's pointless to re-show the dialog if we can't do anything when its options are + // selected, so we don't. + dismiss(); + } + } + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {