Android: onSaveInstanceState in Back button

后端 未结 2 1856
离开以前
离开以前 2021-01-19 18:02

I am developing an application in which i am overriding the back button. I created a check box. On click of which i am calling intent for:

startActivityforR         


        
2条回答
  •  遇见更好的自我
    2021-01-19 18:25

    Now but from second activity if i click on device back button the state is not maintained.

    onSaveInstanceState() is mostly used for configuration changes (e.g., rotating the screen).

    So what should i do to maintain the state on back button

    Most likely, there is no "state" that needs to be "maintained", outside of your data model. Your activity needs to update its data model: files, database, preferences, ContentProvider, some singleton that is your in-memory data model manager, whatever.

提交回复
热议问题