MainActivity.kt — the first screen
Every Android app has an entry point — MainActivity. The template creates it; let's read what it does, because with Compose everything starts here.
class MainActivity : ComponentActivity()— the screen the system launches first.setContent { ... }— "from here the UI is drawn by Compose, not the old XML".PicaTheme { ... }— the Material 3 theme (colors, typography). The template generates it incore/theme/Theme.kt; it uses the phone's dynamic color on Android 12+.Surface { Greeting("Pica") }— the first visible content.@Composable fun Greeting(...)— a function that returns UI.@Previewlets you see it in Android Studio without running.
The key idea: UI in Compose is functions, not XML files. Greeting is the simplest example of that.
Verify. Run the app (Run ▶) on an emulator or phone. The screen should show:
Hello Pica!
A single screen with one line of text. That's all for now — but it's YOUR app, live on a device.
Tip. In the real Pica, this
Greeting("Pica")becomesPicaNavHost()in lesson 4 — the whole navigation graph (menu → detail → cart → checkout). For now we keep one screen: first we need content (the menu), and we build that next lesson. The theme (PicaTheme) and the entry point (MainActivity) stay the same all course — only what they show changes.