Android - What To Put In Onpause And Onsaveinstancestate
I am trying to figure out what should go in onPause and what in onSaveInstanceState. Taking the example of a card game. I want to restore the hand being played to exactly the same
Solution 1:
Basic rule to follow - use onSaveInstanceState if you want to put data into a bundle to be by onCreate. Use onPause to write persistent data that can be read during onResume.
In your case you will probably want to put most of your suspend logic in onPause. I find that I almost always use onPause for most suspend logic since my apps (games) don't usually reduce to something that can fit into a bundle easily.
Post a Comment for "Android - What To Put In Onpause And Onsaveinstancestate"