To safely cast an Activity to ComponentActivity, I usually create an extension function like this:
fun Activity.asComponentActivity(): ComponentActivity? {
return this as? ComponentActivity
}
So then I use this to call this registerForActivityResult.
This should be fixed from AS as @Ekalips is saying.