Retained Fragments: As Nice as All That?
Retained fragments: pretty nifty, right? Yes! They are indeed nifty. They appear to solve all the problems that pop up from activities and fragments being destroyed on rotation. When the device configuration changes, you get the most appropriate resources by creating a brand-new view, and you have an easy way to retain data and objects.
You may wonder why you would not retain every fragment or why fragments are not retained by default. At times, Android seems to discourage retaining fragments with user interfaces. We are not sure why that is the case, but it may end up causing problems in the future if the Android team thinks little of this feature.
Keep in mind, however, that retained fragments are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access