Junior — Middle
Can you explain what is meant by the term 'Activity' in Android development?
sobes.tech AI
Answer from AI
In Android development, an Activity is one of the main components of an application, representing a screen with a user interface. Simply put, an Activity is a window or page with which the user interacts.
Each Activity manages the lifecycle of its interface and is responsible for handling user actions on that screen. For example, in an application with multiple screens, each screen is usually implemented as a separate Activity.
Example:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // bind layout to Activity
}
}
Thus, an Activity is the entry point for user interaction with the application on a specific screen.