Activity
In the context of Android app development, an "Activity" is a fundamental component of the Android application framework. It represents a single screen with a user interface where users can interact. An app typically consists of multiple activities that work together to provide the overall user experience.
Here are key points about Android Activities:
-
User Interface (UI):
- An Activity is responsible for presenting a visual user interface for interaction. This interface is defined using XML layout files that specify the arrangement of UI elements such as buttons, text fields, images, etc.
-
Lifecycle:
- Activities have a lifecycle that defines their states and transitions. The key methods in the lifecycle include
onCreate()
, onStart()
, onResume()
, onPause()
, onStop()
, and onDestroy()
. These methods allow developers to manage resources, handle user interactions, and respond to changes in the app's state.
-
Intent:
- Activities are typically started by sending an "Intent," which is a message that specifies the action to be performed. Intents can include information such as the target activity, data to be passed, and flags indicating how the activity should be launched.
-
Task and Back Stack:
- Activities are organized into tasks, and the Android system maintains a back stack that contains the history of activities. When a new activity is started, it is added to the stack, and users can navigate back through the stack to return to previous activities.
-
Communication Between Activities:
- Activities can communicate with each other using Intents. Data can be passed between activities through Intent extras. Additionally, activities can return results to the calling activity.
-
Manifest Declaration:
- Each activity in an Android app must be declared in the app's manifest file (AndroidManifest.xml). This declaration includes information such as the activity's name, the main intent filter, and any required permissions.
Thank You.