Fragment's onSaveInstanceState() is never called

后端 未结 6 1152
醉酒成梦
醉酒成梦 2020-11-30 10:31

I\'m trying to save data in a Fragment\'s onSaveInstanceState(), but the method is never called.

Can someone help?

public class MyFragment extends Fr         


        
6条回答
  •  情深已故
    2020-11-30 11:33

    Try calling FragmentManager#saveFragmentInstanceState and Fragment#setInitialSavedState in Activity. You call saveFragmentInstanceState, then framework will call onSaveInstanceState. And you call setInitialSavedState, then framework will call onCreateView with no null argument 'Bundle savedInstanceState'.

提交回复
热议问题