1

The guide from Android developers is rather ambiguous.

The default implementation of onSaveInstanceState() saves information about the state of the activity’s view hierarchy, such as the text in an EditText widget or the scroll position of a ListView widget.

These get stored as far as I know:

  • the Intent that started your activity (found out through testing)
  • properties of the objects in the Activity's view graph if they have been given an Id, presumably
  • Fragments that are not in the back stack and which have been set to retain their instance (Fragment#setRetainInstance(boolean))

However, in the API I have not found such contract being described and I am not sure whether this list is exhaustive either. I have not been able to find any documentation which clearly expresses what gets stored.

This is a possible duplicate to this question, however that question doesn't ask for sources or exhaustiveness and the answers there do not provide that. Are developers supposed to just look into the SDK in every single View, Activity, Fragment, AutofillManager etc. they use to see what gets saved and what doesn't? What are the guarantees?

Radu Stefan Popescu
  • 199
  • 1
  • 3
  • 14
  • nothing gets saved by default. It's entirely on your own to use it. – Chisko Apr 13 '18 at 18:14
  • 1
    Possible duplicate of [Android View - What is automatic saved and restored in Activity](https://stackoverflow.com/questions/45314262/android-view-what-is-automatic-saved-and-restored-in-activity) – Chisko Apr 13 '18 at 18:15
  • some things do get saved by default if you browse the SDK: the window hierarchy using ```Window#saveHierarchyState()```, but not sure what this does explicitly; some fragments; and something related to the AutofillManager, but this is only in ```Activity``` and it is not documented in the SDK API. – Radu Stefan Popescu Apr 13 '18 at 18:25

0 Answers0