Junior — Middle
Can you describe the main stages of the Activity component lifecycle in Android?
sobes.tech AI
Answer from AI
The lifecycle of an Activity in Android consists of several main stages, each corresponding to the invocation of certain methods:
- onCreate() — initializing the Activity, setting up the interface, preparing data.
- onStart() — the Activity becomes visible to the user.
- onResume() — the Activity starts interacting with the user (comes to the foreground).
- onPause() — the Activity loses focus but is still visible (for example, a dialog appears or another Activity partially overlaps).
- onStop() — the Activity is completely hidden but still in memory.
- onDestroy() — the Activity is destroyed, resources are released.
There are also methods onRestart() (called when the Activity is restarted after onStop) and additional states, but the listed ones are the main stages of the lifecycle.