Junior — Middle
What is the main role of the Activity component in Android application architecture?
sobes.tech AI
Answer from AI
An Activity in Android is a fundamental component representing a single screen with a user interface. Its main role is to manage the lifecycle of the screen and interact with the user.
Tasks of an Activity:
- Displaying UI and handling user actions.
- Managing transitions between screens (launching other Activities).
- Handling the lifecycle (creation, pause, resume, destruction) for efficient resource use.
Example: When launching an app, the main Activity usually starts, showing the main screen. When a button is pressed, another Activity can be launched to display details.