Austin Johnson Austin Johnson - 1 year ago 77
Android Question

Is onPause() or onStop() called even if phone dies due to lack of power?

If I, for example, need to keep some very important data which can user edit within my app, would I need to save them every time user changes such data or is it ok if I would save it within onPause(), onStop() or onDestroy() methods?

Can somehow application end without any of those methods calling? (For instance when battery runs out)

Answer Source

This certainly can't be done in onDestroy(). According to the documentation:

There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

So yes, the application can end without calling any of the lifecycle methods.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download