Its not necessary that it would be called when the activity is finishing. onPause
is sure to be called. If you read the documentation of onDestroy
, it says:
Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either onPause() or onSaveInstanceState(Bundle), not here.
If you see this question Activity OnDestroy never called? , the answer here says:
onDestroy()
is called only when system is low on resources(memory, cpu time and so on) and makes a decision to kill your activity/application or when somebody calls finish() on your activity.
So, when you press that button to exit the application, its not necessary that onDestroy
will be called.