onActivityResult Deprecated
Morons opened this issue · 1 comments
Morons commented
can the onActivityResult Deprecated be fixed / updated!?
jasonsaruulo commented
I had a brief look at the MediaStore sample. At least here the fix could be as follows.
val deletePermissionLauncher = registerForActivityResult(StartIntentSenderForResult()) {
if (it.resultCode == Activity.RESULT_OK) {
viewModel.deletePendingImage()
}
}
viewModel.permissionNeededForDelete.observe(this, Observer { intentSender ->
intentSender?.let {
// On Android 10+, if the app doesn't have permission to modify
// or delete an item, it returns an `IntentSender` that we can
// use here to prompt the user to grant permission to delete (or modify)
// the image.
deletePermissionLauncher.launch(IntentSenderRequest.Builder(it).build())
}
})
I think then we can remove the override for onActivityResult
in MainActivity
.
If that approach is accepted, I could have a look at the other samples to see whether similar can be applied.