Skip to the workspace
Pebellslearn by building
The Fundamentals  ›  Capstone Project

Hello World — Sprout's First Screen

Create a Basic Hello World App 15 minA minimal app is one activity, declared in the manifest as the launcher entry point, that sets its content when it is created.

android / Hello World — Sprout's First Screen

Explore each scene at your own pace.

01 · The rule

The rule

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.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.