Complete the code to create an Intent to start SecondActivity from MainActivity.
val intent = Intent(this, [1]::class.java) startActivity(intent)
::class.java after the activity name.The Intent constructor needs the target activity class. Here, SecondActivity is the destination.
Complete the code to add extra data "username" to the Intent.
val intent = Intent(this, SecondActivity::class.java) intent.[1]("username", "Alice") startActivity(intent)
getExtra which is for retrieving data, not adding.addExtra or setExtra.Use putExtra to add extra data to an Intent before starting an activity.
Fix the error in the Intent creation to start ThirdActivity.
val intent = Intent(this, [1])
startActivity(intent)::class.java.The Intent constructor requires the class reference with ::class.java in Kotlin.
Fill both blanks to create an Intent and start FourthActivity.
val intent = Intent([1], [2]::class.java) startActivity(intent)
The first argument is the current context, usually this in an activity. The second is the target activity class.
Fill all three blanks to create an Intent, add an extra "age", and start FifthActivity.
val intent = Intent([1], [2]::class.java) intent.[3]("age", 25) startActivity(intent)
Use this as context, FifthActivity as target, and putExtra to add data.