Challenge - 5 Problems
Intent Navigator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when this Intent code runs?
Consider this Kotlin code inside an Android activity. What will the user see after clicking the button?
Android Kotlin
val intent = Intent(this, SecondActivity::class.java)
startActivity(intent)Attempts:
2 left
💡 Hint
Intent is used to start a new screen (activity).
✗ Incorrect
The Intent specifies SecondActivity as the target, so startActivity launches that screen.
📝 Syntax
intermediate2:00remaining
Which option correctly creates an Intent to start DetailActivity?
Choose the correct Kotlin code snippet to start DetailActivity from the current activity.
Attempts:
2 left
💡 Hint
Intent constructor needs context and target activity class.
✗ Incorrect
Option A correctly uses 'this' as context and DetailActivity::class.java as target.
❓ lifecycle
advanced2:00remaining
What happens to the current activity after startActivity(intent)?
After calling startActivity(intent) to open a new activity, what is the state of the current activity?
Attempts:
2 left
💡 Hint
Think about Android activity lifecycle when switching screens.
✗ Incorrect
The current activity is paused and stopped but kept in the back stack for possible return.
🔧 Debug
advanced2:00remaining
Why does this Intent code cause a crash?
Given this code snippet, why does the app crash when startActivity is called?
val intent = Intent(this, SecondActivity::class.java)
startActivity(intent)
Android Kotlin
class FirstActivity : AppCompatActivity() { fun openSecond() { val intent = Intent(this, SecondActivity::class.java) startActivity(intent) } } class SecondActivity : AppCompatActivity() {}
Attempts:
2 left
💡 Hint
Android requires all activities to be registered in the manifest.
✗ Incorrect
If SecondActivity is not in the manifest, the system cannot start it, causing a crash.
🧠 Conceptual
expert2:00remaining
What is the purpose of Intent flags in activity navigation?
Why would a developer add flags like FLAG_ACTIVITY_CLEAR_TOP to an Intent before starting an activity?
Attempts:
2 left
💡 Hint
Flags affect how Android handles activity instances and navigation history.
✗ Incorrect
Flags like FLAG_ACTIVITY_CLEAR_TOP modify the back stack to avoid duplicate activities or clear existing ones.