Android development throws a lot at you: Activities, Fragments, Intents, Gradle, ViewModels, LiveData, and now Jetpack Compose. The problem isn’t that it’s hard. It’s that nobody explains how the pieces connect.
The Mental Model
Think of an Android app as three layers:
- UI layer: what the user sees (Compose UI / XML layouts)
- State layer: what the UI depends on (ViewModel)
- Data layer: where data comes from (Room DB, network API)
Activities and Intents
An Activity is a screen. An Intent is a message: “open this screen” or “perform this action.”
// Navigate to a new screen
val intent = Intent(this, ProfileActivity::class.java)
startActivity(intent)
Why ViewModels Matter
Without ViewModels, your data can be destroyed on rotation or process death. ViewModels keep state alive across configuration changes.
class ProfileViewModel : ViewModel() {
private val _name = MutableStateFlow("")
val name: StateFlow<String> = _name
fun loadProfile() {
// fetch data, update _name
}
}
Compose (The Modern UI)
Compose is declarative UI. You describe what the UI should look like for a given state.
@Composable
fun ProfileScreen(vm: ProfileViewModel) {
val name by vm.name.collectAsState()
Text(text = "Hello, $name")
}
My Recommendation for Beginners
- Learn Kotlin basics (null safety, data classes, coroutines)
- Build 2-3 simple Compose screens
- Add ViewModel and StateFlow
- Add Room database for persistence
- Call a real API with Retrofit
Android becomes enjoyable once you stop memorizing components and start thinking in layers: UI state data. That one mental model will carry you a long way.
