/
Android Activities
Save to my account
Sign up
Report Bug
Android Activities
Android Activities
Study
Question
What is an activity in the context of Android applications?
Answer
An activity is a component of an Android application that represents a single screen with a user interface, containing UI elements like buttons, text fields, images, and interactive widgets. It manages user interactions and responses.
Question
How do activities relate to the user experience in an Android app?
Answer
Activities represent different screens or windows within the app, allowing users to interact with specific interfaces dedicated to particular tasks, such as displaying data, modifying information, or performing actions.
Question
What types of tasks might different activities in an Android app be dedicated to?
Answer
Activities can be dedicated to displaying data (e.g., contact lists), modifying information (e.g., user profile), or executing actions (e.g., playing a video).
Question
What are the three main files associated with an Android activity?
Answer
1) The AndroidManifest.xml file where the activity is declared, 2) An XML layout file in the /res/layout/ directory that defines the UI design, and 3) A Java file that controls the activity's behavior.
Question
How is an activity declared as the startup screen in an Android application?
Answer
In the AndroidManifest.xml file, an activity is declared inside an <activity> tag, and the <intent-filter> tag indicates which activity should launch first at app startup.
Question
In Android programming, how are activities implemented?
Answer
Activities are implemented as classes in Java that subclass android.app.Activity.
Question
What is the activity stack (pile d'activité) in Android, and how does it function?
Answer
The activity stack manages the order of activities. When a new activity starts, it is placed on top of the stack and becomes active. The previous activity remains underneath, and control returns to it only when the top activity closes. Pressing the Back button moves the focus to the next activity down the stack.
Question
What are the different states an Android activity can be in, particularly regarding visibility?
Answer
An activity can be: Active (running in the foreground), Paused (partially visible but not in the foreground), Stopped (invisible and not in foreground), or Dead (not launched).
Question
What happens when an activity moves from active to paused state?
Answer
The activity remains visible but loses focus because another activity or notification has taken the foreground.