Fixes #1933428. Call onPrepareDialog() on managed dialogs after their onCreate() is finished.
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index df50f77..6c2560d 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -857,7 +857,7 @@
if (dialogState != null) {
// Calling onRestoreInstanceState() below will invoke dispatchOnCreate
// so tell createDialog() not to do it, otherwise we get an exception
- final Dialog dialog = createDialog(dialogId, false);
+ final Dialog dialog = createDialog(dialogId, dialogState);
mManagedDialogs.put(dialogId, dialog);
onPrepareDialog(dialogId, dialog);
dialog.onRestoreInstanceState(dialogState);
@@ -865,13 +865,13 @@
}
}
- private Dialog createDialog(Integer dialogId, boolean dispatchOnCreate) {
+ private Dialog createDialog(Integer dialogId, Bundle state) {
final Dialog dialog = onCreateDialog(dialogId);
if (dialog == null) {
throw new IllegalArgumentException("Activity#onCreateDialog did "
+ "not create a dialog for id " + dialogId);
}
- if (dispatchOnCreate) dialog.dispatchOnCreate(null);
+ dialog.dispatchOnCreate(state);
return dialog;
}
@@ -2407,7 +2407,7 @@
}
Dialog dialog = mManagedDialogs.get(id);
if (dialog == null) {
- dialog = createDialog(id, true);
+ dialog = createDialog(id, null);
mManagedDialogs.put(id, dialog);
}