Recall & Review
beginner
What is the purpose of
ActivityResultLauncher in Android Kotlin?It is used to launch another activity and receive a result back asynchronously, replacing the older
startActivityForResult method.Click to reveal answer
beginner
How do you register for an activity result in Android Kotlin?
You use
registerForActivityResult() with an ActivityResultContract and a callback to handle the result.Click to reveal answer
intermediate
What is an
ActivityResultContract?It defines the input type needed to start an activity and the output type returned as a result, helping to standardize communication between activities.
Click to reveal answer
intermediate
Why is the new activity result API preferred over
startActivityForResult?Because it is lifecycle-aware, safer, and easier to manage results without overriding
onActivityResult.Click to reveal answer
beginner
What happens if you try to launch an activity result without registering the launcher first?
The app will crash or the result will not be delivered because the launcher is not initialized to handle the result callback.
Click to reveal answer
Which method replaces
startActivityForResult in modern Android Kotlin development?✗ Incorrect
registerForActivityResult is the new recommended way to launch activities for results.What is the role of the callback passed to
registerForActivityResult?✗ Incorrect
The callback receives the result data when the launched activity finishes.
Which class defines the input and output types for activity results?
✗ Incorrect
ActivityResultContract specifies how to create the intent and parse the result.What lifecycle benefit does the new activity result API provide?
✗ Incorrect
The API respects the lifecycle of the component to prevent leaks and crashes.
How do you launch the activity after registering the launcher?
✗ Incorrect
You use the
launch() method on the registered launcher to start the activity.Explain how to use the new activity result API in Android Kotlin to get data back from another activity.
Think about how you prepare, start, and receive results from another screen.
You got /4 concepts.
Describe the advantages of the new activity result API compared to the old startActivityForResult method.
Focus on safety and ease of use improvements.
You got /4 concepts.