Challenge - 5 Problems
First Android App Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this Android app display?
Consider this simple Android app code snippet. What text will appear on the screen when the app runs?
Android Kotlin
import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.material3.Text import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { Greeting("Android Learner") } } } @Composable fun Greeting(name: String) { Text(text = "Hello, $name!") }
Attempts:
2 left
💡 Hint
Look at the Greeting composable and what string it uses.
✗ Incorrect
The Greeting composable displays the text "Hello, $name!" where name is "Android Learner" passed from setContent. So the screen shows "Hello, Android Learner!".
❓ lifecycle
intermediate1:30remaining
When is onCreate() called in an Android app?
In the Android app lifecycle, when does the onCreate() method run?
Attempts:
2 left
💡 Hint
Think about the first step when an activity starts.
✗ Incorrect
onCreate() is called once when the activity is first created, before it becomes visible to the user.
📝 Syntax
advanced2:00remaining
What error does this Kotlin code produce?
Look at this Kotlin code snippet for an Android app. What error will it cause?
Android Kotlin
import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.material3.Text class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { Text(text = "Welcome") } } fun Text(text: String) { println(text) } }
Attempts:
2 left
💡 Hint
Check if defining a function named Text conflicts with Compose's Text composable.
✗ Incorrect
Defining a function named Text in the same scope conflicts with the Compose Text composable, causing a compilation error due to ambiguity.
advanced
2:00remaining
What happens when this navigation code runs?
Given this Android Jetpack Compose navigation snippet, what screen will the user see after clicking the button?
Android Kotlin
import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.navigation.NavController @Composable fun FirstScreen(navController: NavController) { Button(onClick = { navController.navigate("second") }) { Text("Go to Second") } } @Composable fun SecondScreen() { Text("Second Screen") }
Attempts:
2 left
💡 Hint
Look at what navController.navigate("second") does.
✗ Incorrect
Calling navController.navigate("second") moves the app to the SecondScreen composable, which displays "Second Screen" text.
🧠 Conceptual
expert2:30remaining
Why use setContent in an Android Compose app?
What is the main purpose of calling setContent in an Android app using Jetpack Compose?
Attempts:
2 left
💡 Hint
Think about how Compose replaces XML layouts.
✗ Incorrect
setContent replaces the traditional XML layout by setting the UI content directly with composable functions in Kotlin code.