Android - Save activity state when starting new activity

前端 未结 1 1906
别那么骄傲
别那么骄傲 2021-01-07 10:34

I\'m currently working an application that should have the following behavior : In one of the activities, the user can select different items into a list. While doing that,

相关标签:
1条回答
  • 2021-01-07 10:55

    I know I could use the Bundle savedInstanceState to manually save and restore the state by overriding onPause, onResume, on Create (etc), but there is actually lots of data in custom components that are not easily serializable, so I'd like to avoid that.

    What you would "like" does not much matter. You need this code anyway to handle configuration changes (e.g., switch from portrait to landscape). Please implement onSaveInstanceState() and onRestoreInstanceState(), then back out all the rest of the inappropriate hacks that you have in your previous paragraph (e.g., singleInstance, alwaysRetainTaskState).

    0 讨论(0)
提交回复
热议问题