For Viewwith identifiers, they will be automatically saved when called super.onSaveInstanceState(outState);.
For Fragmentadded in Activity, in which cases will it be recreated when it Activitywill be recreated (for example, screen rotation), and in which cases it will not? Determine what? What is the rule?
So far I have tried the following cases. But trial-n-error does not mean any rules or decisions.
Reboot Cases Fragment:
- The usual case:
FragmentTransaction.add()to a layout with an identifier. - Snippet without user interface:
FragmentTransaction.add()tag only
Cases when NOT isFragment stored :
- When skipping
super.onSaveInstanceState(outState);. - Restored
Fragmentin user interface without corresponding identifier.
What is the general rule? Anything I missed in the documentation?
Thanks in advance.
Edit:
In my understanding and experiments, ALL dynamically (software) added Fragmentare saved when they are called Activity super.onSaveInstanceState(outState).
- ALL dynamically (software) added
Fragments includes,Fragment only with tag (without interface),Fragmentbound to View(with user interface)- and
Fragmentwith both the user interface and the tag. - (are there any other types?)
Fragment , , Fragment . :
04-08 11:41:22.445: W/PhoneWindow(9853): Previously focused view reported id 2131165226 during save, but can't be found during restore.
, .
!