So I've come across something with my Android app which I am apparently not handling well (or at all).
If I open my app, then press the home button (so the app is now running in the background), then wait a long time (perhaps do other things in the meantime), and then open the app again, I get weird behavior. Specifically, the app remembers what activity it was on, but it doesn't remember much else about that activity.
In my scenario, I have a puzzle game which is drawn onto the activity. When I start up the app again at that later time, the activity for interacting with the puzzle opens (as if the app was just put on hold), but the puzzle itself is gone. This only happens after a long period of time running the game in the background.
Furthermore, my app is not listed on my device as an "Active App" when this happens, which leads me to believe Android has closed the app due to inactivity, but saved the app's state or something (since reopening the app doesn't start the launcher activity). I suppose the other possibility is that the puzzle data was garbage collected.
So my question is: what would be the "correct" way of preserving the puzzle data? My initial assumption would be saving it in a temp file, but I'm not sure when I should tell my app to create that temp file, or if this is even a valid assumption.