How to restore dialogue, etc. after turning the screen? For example, run alertDialog to tell the user some information. then the user rotates the screen to a different orientation. How to restore alertDialog? Can someone help me do this? Thanks!
Added later:
I looked at the Android source code and found the following things:
Dialogs are stored in mManagedDialogs , and related information:
mManagedDialogs = new SparseArray<ManagedDialog>();
onSaveInstanceState related:
final void performSaveInstanceState(Bundle outState) { onSaveInstanceState(outState); saveManagedDialogs(outState); }
In saveManagedDialogs it has something to mManagedDialogs with mManagedDialogs .
onRestoreInstanceState related:
final void performRestoreInstanceState(Bundle savedInstanceState) { onRestoreInstanceState(savedInstanceState); restoreManagedDialogs(savedInstanceState); }
In restoreManagedDialogs it has something to mManagedDialogs with mManagedDialogs .
As you can see, for an advanced function, you must perform backup and restore yourself. It can be a night mare when you have subtle, customizable dialogs. I have not tried a complex dialog (there is an input EdiText, listView, let's say). Thus, I would like to warn users: never rotate the screen when entering your information in a dialog ... OR, block the rotation dynamically when the dialog is displayed.
Thanks to all the people who answered me. I hope my information helps you too.
android rotation dialog restore
Henry Sou
source share