0
0
Android Kotlinmobile~10 mins

Intent for activity navigation in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an Intent to start SecondActivity from MainActivity.

Android Kotlin
val intent = Intent(this, [1]::class.java)
startActivity(intent)
Drag options to blanks, or click blank then click option'
ASecondActivity
BMainActivity
CApplication
DContext
Attempts:
3 left
💡 Hint
Common Mistakes
Using the current activity class instead of the target activity.
Forgetting to add ::class.java after the activity name.
2fill in blank
medium

Complete the code to add extra data "username" to the Intent.

Android Kotlin
val intent = Intent(this, SecondActivity::class.java)
intent.[1]("username", "Alice")
startActivity(intent)
Drag options to blanks, or click blank then click option'
AsetExtra
BgetExtra
CaddExtra
DputExtra
Attempts:
3 left
💡 Hint
Common Mistakes
Using getExtra which is for retrieving data, not adding.
Using non-existent methods like addExtra or setExtra.
3fill in blank
hard

Fix the error in the Intent creation to start ThirdActivity.

Android Kotlin
val intent = Intent(this, [1])
startActivity(intent)
Drag options to blanks, or click blank then click option'
AThirdActivity.class
BThirdActivity::class.java
CThirdActivity
DThirdActivity()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the activity name without ::class.java.
Passing an instance of the activity instead of the class.
4fill in blank
hard

Fill both blanks to create an Intent and start FourthActivity.

Android Kotlin
val intent = Intent([1], [2]::class.java)
startActivity(intent)
Drag options to blanks, or click blank then click option'
Athis
BapplicationContext
CFourthActivity
DMainActivity
Attempts:
3 left
💡 Hint
Common Mistakes
Using applicationContext instead of this, which can cause issues with UI.
Mixing up the order of arguments.
5fill in blank
hard

Fill all three blanks to create an Intent, add an extra "age", and start FifthActivity.

Android Kotlin
val intent = Intent([1], [2]::class.java)
intent.[3]("age", 25)
startActivity(intent)
Drag options to blanks, or click blank then click option'
Athis
BFifthActivity
CputExtra
DapplicationContext
Attempts:
3 left
💡 Hint
Common Mistakes
Using applicationContext instead of this for context.
Using wrong method names for adding extras.
Mixing up the order of arguments.