savedInstanceState when restoring fragment from back stack

后端 未结 4 430
礼貌的吻别
礼貌的吻别 2021-01-31 15:53

Can I use savedInstanceState() to save the state when removing a fragment, then restore the state when I pop the fragment off the back stack? When I restore the fr

4条回答
  •  情歌与酒
    2021-01-31 16:18

    FWIW, I hit this as well, but in my case onSaveInstanceState was called properly and I pushed in my state data when a new activity fragment was brought up on the smartphone. Same as you, the onActivityCreated was called w/ savedInstanceState always null. IMHO, I think it's a bug.

    I worked around it by creating a static MyApplication state and putting the data there for the equivalent of "global variables"...

提交回复
热议问题