I’ve chosen to save the persistent application state in the OnPause() method to my database because OnPause() is guaranteed to be called before the application gets killed according to the documentation of the activity life cycle.
Now I am facing following behaviour using eclipse and avd emulator (api level 8):
1. I start my application via eclipse – Instance1
2. I start my application via eclipse again – Instance2
Now Instance1 is being terminated without calling OnPause()!
Could somebody please explain me why OnPause() is not being called? I thought it is guaranteed to be called always. If this is not the case, maybe because of the way eclipse terminates Instance1 process, then I would like to know if I could change this. Thanks a lot.
When you start the application via eclipse, it will effectively rip the rug out from any instance of the same app already running on the device or an emulator. This will never happen in practice, only when running from eclipse.
So you can plan on onPause() always being called.