Reputation: 14658
I have an issue that when I leave the android device idle for a bit (it sleeps and locks, then I have to unlock it), it seems that my OnCreat method is called again because my variables are resetted and the layout is redrawn again! Is there a way I can preserve the state and continues from where it was after its being unlocked (or awaken again)? Thank you very much
Upvotes: 1
Views: 2054
Reputation: 14237
When you go out of your activity (pressing back, a call is received, pressing home, locking, etc) the acitivity calls the onPause()
method and then loses all saved information (unless you use only the provided widgets in the Android framework).
Therefore you need to save that information overriding the onPause()
method. Then you need to load that information in the onResume()
method.
For more information check: http://developer.android.com/reference/android/app/Activity.html
Upvotes: 2
Reputation: 2298
You should understand the life cycle of Activity. I wrote about this problem here:
Interface not reloaded after returning to app from BACK press
Upvotes: 0