0
0
Android Kotlinmobile~5 mins

Activity results in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AlaunchActivity
BstartActivity
ConActivityResult
DregisterForActivityResult
What is the role of the callback passed to registerForActivityResult?
ATo handle the result returned from the launched activity
BTo start the activity
CTo register the activity in the manifest
DTo create a new activity instance
Which class defines the input and output types for activity results?
ABundle
BIntent
CActivityResultContract
DActivityResultLauncher
What lifecycle benefit does the new activity result API provide?
AIt is lifecycle-aware and avoids memory leaks
BIt runs on a background thread
CIt automatically restarts the activity
DIt disables lifecycle callbacks
How do you launch the activity after registering the launcher?
ACall <code>startActivityForResult()</code>
BCall <code>launch()</code> on the <code>ActivityResultLauncher</code>
CCall <code>onActivityResult()</code>
DCall <code>registerForActivityResult()</code> again
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.