What if managing each screen in your app was as easy as flipping a page in a book?
Why Activity concept in Android Kotlin? - Purpose & Use Cases
Imagine you want to build a mobile app with multiple screens, like a login page, a home page, and a settings page. Without a clear way to manage these screens, you might try to put all the code and layouts in one place.
This quickly becomes confusing and hard to control, like trying to read a book where all chapters are jumbled together.
Trying to handle multiple screens manually means writing lots of complicated code to switch views, manage user input, and keep track of what screen is showing.
This is slow to build, easy to break, and hard to fix or improve later.
The Activity concept in Android gives you a simple, organized way to create and manage each screen separately.
Each Activity acts like a single page in your app, handling its own layout and user interactions.
Android helps you switch between Activities smoothly, so your app feels natural and easy to use.
fun showScreen(name: String) {
if (name == "login") {
// show login layout
} else if (name == "home") {
// show home layout
}
}startActivity(Intent(this, HomeActivity::class.java))With Activities, you can build apps with many screens that work well together, making your app organized and user-friendly.
Think of a shopping app: one Activity shows the product list, another shows product details, and another handles the checkout process. Activities keep these parts separate but connected.
Activities represent individual screens in an Android app.
They help organize code and UI for each screen separately.
Android manages switching between Activities smoothly for you.