Fragment's onSaveInstanceState() is never called

后端 未结 6 1160
醉酒成梦
醉酒成梦 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:18

    I encountered the same question with you, and tried onSaveInstanceState() method, but did not work.

    I think onSaveInstanceState() only works for the scenario that user jumps from one activity to another activity and back, it does not work in the scenario that user jumps among fragments in the same activity.

    here is the guide document from Google. http://developer.android.com/guide/components/tasks-and-back-stack.html#ActivityState

提交回复
热议问题