I've finally reached the point in the development of my app where I need to tackle Resume/Pause, etc. My first attempt involved saving program data in Pause and Restoring it in Resume, but that caused restoring when the program hadn't gone away. So as a last resort, I read the documentation.
:sign0012:
So now I've read the tutorials and related info again, but I'm still not sure I have everything straight:
1. When I turn on my device and run my app, Sub Activity_Create runs (with FirstTime = True) followed by Sub Resume running. If I have run the app before and data was saved (game scores, options selected, etc.), then I read that data back in (in Activity_Create or a sub referenced therein) and use it to continue the game.
2. While running my app, which has a single Activity, I press Home (at which point Sub Pause is executed and the game's data are saved to disk) and run some other apps. I return shortly to my app (which Android still has in memory). Resume will run but Activity_Create will not. The app's screen and data will be just where it was and the app will continue as if I had never left. So although app's settings were saved in Pause, I don't have to restore them.
3. Like #2, but I take longer running apps and by the time I get back to my app, it is no longer in memory, so Activity_Create runs (with FirstTime = False, not that I'm using it) and reloads the saved game data to restore the game's scores and settings, then Resume runs.
4. My app runs landscape only, but if both orientations were allowed and the device were rotated, the results would be the same as #3.
5. If I put the device into Sleep mode and later resume my app, then Resume will run but Activity_Create will not and the game will continue where I left off.
6. If I'm running the app and power off the device, Pause will run and save the app's data while the device is powering down, and next time I run the app will be as in #1.
I'm not using the FirstTime flag at all, and only using Resume to enable the timers which were disabled in Pause.
Have I got all this straight?
One possible glitch is that if the user pulls out the SD card, then powers down, the data can't be saved and in Pause, there's nothing that can be done about it (like telling him to put it back in). Right?
:sign0012:
So now I've read the tutorials and related info again, but I'm still not sure I have everything straight:
1. When I turn on my device and run my app, Sub Activity_Create runs (with FirstTime = True) followed by Sub Resume running. If I have run the app before and data was saved (game scores, options selected, etc.), then I read that data back in (in Activity_Create or a sub referenced therein) and use it to continue the game.
2. While running my app, which has a single Activity, I press Home (at which point Sub Pause is executed and the game's data are saved to disk) and run some other apps. I return shortly to my app (which Android still has in memory). Resume will run but Activity_Create will not. The app's screen and data will be just where it was and the app will continue as if I had never left. So although app's settings were saved in Pause, I don't have to restore them.
3. Like #2, but I take longer running apps and by the time I get back to my app, it is no longer in memory, so Activity_Create runs (with FirstTime = False, not that I'm using it) and reloads the saved game data to restore the game's scores and settings, then Resume runs.
4. My app runs landscape only, but if both orientations were allowed and the device were rotated, the results would be the same as #3.
5. If I put the device into Sleep mode and later resume my app, then Resume will run but Activity_Create will not and the game will continue where I left off.
6. If I'm running the app and power off the device, Pause will run and save the app's data while the device is powering down, and next time I run the app will be as in #1.
I'm not using the FirstTime flag at all, and only using Resume to enable the timers which were disabled in Pause.
Have I got all this straight?
One possible glitch is that if the user pulls out the SD card, then powers down, the data can't be saved and in Pause, there's nothing that can be done about it (like telling him to put it back in). Right?