0
0
Android Kotlinmobile~10 mins

Passing data between activities 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.

Android Kotlin
val intent = Intent(this, [1]::class.java)
startActivity(intent)
Drag options to blanks, or click blank then click option'
ASecondActivity
BMainActivity
CAppCompatActivity
DIntent
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 put a string extra named "username" into the Intent.

Android Kotlin
intent.putExtra("username", [1])
Drag options to blanks, or click blank then click option'
A"userName"
Busername
CuserName
Duser_name
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the variable name, which sends the literal text instead of the variable's value.
Using the key name instead of the variable.
3fill in blank
hard

Fix the error in retrieving the string extra named "username" from the Intent.

Android Kotlin
val user = intent.[1]("username")
Drag options to blanks, or click blank then click option'
AgetExtra
BgetExtraString
CgetString
DgetStringExtra
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that does not exist like getExtraString.
Using getString which is not a method of Intent.
4fill in blank
hard

Fill both blanks to safely retrieve an integer extra named "age" with a default value of 0.

Android Kotlin
val age = intent.[1]("age", [2])
Drag options to blanks, or click blank then click option'
AgetIntExtra
BgetExtraInt
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong method name like getExtraInt.
Forgetting to provide a default value.
5fill in blank
hard

Fill all three blanks to create an Intent, put a boolean extra "isAdmin", and start the activity.

Android Kotlin
val intent = Intent(this, [1]::class.java)
intent.[2]("isAdmin", [3])
startActivity(intent)
Drag options to blanks, or click blank then click option'
AAdminActivity
BputExtra
Ctrue
DMainActivity
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong activity class.
Using a wrong method name instead of putExtra.
Passing the string "true" instead of the boolean true.