My application crashes after idling for a long time in the background. I debugged and found the reason that it is crashing is due to a NullPointerException. Exc
If you can, store it in other methods. If its complex data structures, you may have to restart the app. For example, I have a User singleton in my app that holds login info for my server. I couldn't save those if I tried- a lot of the data is hidden in AWS variables. What I had to do was detect when we were being relaunched from the home page after being cleaned up (as opposed to just being restarted) and launched my starting activity, then finished the current activity. And I had to add that to every activity in my app.