frankiesardo/icepick

icepick+dialogfragment=no state saved?

Closed this issue · 1 comments

Hi. I am using icepick extensively. What I've faced recently is something I cannot understand - it's either misuse on my end or bug of icepick. Context:

  1. Got base abstract class that inherits from DialogFragment and has Icepick.saveInstanceState call in onSaveInstanceState as well as Icepick.restoreInstanceState in onCreateView.
  2. Got concrete dialog class that inherits from the above abstract class
  3. Got something like "@State String mName;" in p.2

What I'm observing is that state (value of mName) is not saved when hosting activity and fragment gets killed. onSaveInstanceState (with Icepick.saveInstanceState) is called while activity/fragments are dying. onCreateView (with Icepick.restoreInstanceState) is called when activity gets recreated.

When I do something like "outState.putString("key", mName)" in onSaveInstanceState, and mName = savedInstanceState.getString("key") in onCreateView - it works perfectly.

Closing this as stale issue