Complete the code to declare a basic Activity class in Kotlin.
class MainActivity : [1]() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
The MainActivity class must extend AppCompatActivity to be a valid Activity.
Complete the code to set the layout resource for the Activity.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
[1](R.layout.activity_main)
}The method setContentView sets the UI layout for the Activity.
Fix the error in the Activity lifecycle method override.
override fun onStart() {
super.[1]()
// Additional code here
}When overriding onStart, call super.onStart() to maintain lifecycle behavior.
Fill both blanks to start a new Activity from the current one.
val intent = Intent(this, [1]::class.java) [2](intent)
To start a new Activity, create an Intent with the target Activity class and call startActivity with it.
Fill all three blanks to pass data to another Activity using Intent extras.
val intent = Intent(this, [1]::class.java) intent.[2]("username", "Alice") [3](intent)
Use putExtra to add data to the Intent, then call startActivity to launch the target Activity.
