Hello World — Sprout's First Screen
Time to put something on the screen. A Hello World app looks tiny, but it contains the three pieces every Android app is built on: a manifest entry, an activity, and some content. Understand these and every later lesson slots into place.
The rule
The manifest points to the door; onCreate paints the room.
First, the manifest declares an activity and marks it as the app's entry point:
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>MAIN means "this is where the app starts" and LAUNCHER means "show an icon for it in the app drawer". exported="true" lets the launcher, which is another app, open it.
Second, the activity sets its content when it is created:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Text("Hello, Sprout!")
}
}
}onCreate is called by the system, not by you. setContent takes a composable, here a single Text, and makes it the screen.