Challenge - 5 Problems
Android Project Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the default launcher activity in a new Android project?
When you create a new Android project in Android Studio with the default settings, which activity is set as the launcher activity that opens first when the app starts?
Attempts:
2 left
💡 Hint
Think about the activity Android Studio creates automatically for you.
✗ Incorrect
The default activity created by Android Studio in a new project is named MainActivity and it is set as the launcher activity in the manifest.
❓ lifecycle
intermediate2:00remaining
What lifecycle method is called first when the app starts?
In the default MainActivity of a new Android project, which lifecycle method is called first when the app is launched?
Attempts:
2 left
💡 Hint
This method is where you usually set your layout.
✗ Incorrect
The onCreate() method is the first lifecycle callback called when the activity is created and is where you initialize your UI.
📝 Syntax
advanced2:00remaining
Which Kotlin code snippet correctly sets the content view in MainActivity?
In the MainActivity.kt file of a new Android project, which code correctly sets the layout resource named activity_main as the content view?
Android Kotlin
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Set content view here } }
Attempts:
2 left
💡 Hint
The layout resource is accessed via R.layout.
✗ Incorrect
The correct way to set the layout is using setContentView(R.layout.activity_main). Using R.id or strings will cause errors.
advanced
2:00remaining
What happens if you forget to declare MainActivity in AndroidManifest.xml?
If you create MainActivity.kt but do not add it to AndroidManifest.xml, what will happen when you try to run the app?
Attempts:
2 left
💡 Hint
Android needs to know which activity to launch first.
✗ Incorrect
If MainActivity is not declared in the manifest, the system cannot find the launcher activity and throws ActivityNotFoundException at runtime.
🧠 Conceptual
expert2:00remaining
Why does Android Studio create a Gradle build file in a new project?
When you create a new Android project, Android Studio generates build.gradle files. What is the main purpose of these Gradle files?
Attempts:
2 left
💡 Hint
Think about how the app knows which libraries to include and how to compile.
✗ Incorrect
Gradle build files tell Android Studio how to compile the app and which libraries to include, managing dependencies and build settings.