Sobes.tech
Junior — Middle

Is the onDestroy method always called when an Activity is destroyed in Android?

sobes.tech AI

Answer from AI

The onDestroy() method in Android is not guaranteed to be called when an Activity is destroyed. The system may kill the application process without calling this method, for example, due to low memory or a crash. Therefore, you should not rely on onDestroy() for critical operations such as saving data. It is better to use onPause() or onSaveInstanceState() methods to save state.