Issue
I tried:
val getUpdates = (context as Activity).registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK && result.data != null) {
}
}
inside RecyclerView and get: Unresolved reference: registerForActivityResult
Is it not possible inside RecyclerView?
Solution
What you're attempting to do will result in a crash. The result callback must be registered at Activity creation (ie as a field/variable of the Activity)
the callback must be unconditionally registered every time your activity is created, even if the logic of launching the other activity only happens based on user input or other business logic.
See the docs for more details
Answered By - Alvin Dizon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.