Junior — Middle
Under what conditions can the onDestroy method in an Activity be skipped or not called in the lifecycle?
sobes.tech AI
Answer from AI
The onDestroy() method in an Activity may not be called in the following cases:
- If the system abruptly terminates the application process to free resources (for example, due to low memory), onDestroy() may be skipped.
- When finishing an activity via finish(), onDestroy() is called, but if the application crashes, the call may not occur.
- During a configuration change (such as screen rotation), the system may destroy the Activity and create a new one, calling onDestroy(), but in some cases, if the system restores the Activity from a saved state, onDestroy() may not be explicitly called.