Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onActivityResult Deprecated #71

Open
Morons opened this issue Jan 27, 2021 · 1 comment
Open

onActivityResult Deprecated #71

Morons opened this issue Jan 27, 2021 · 1 comment

Comments

@Morons
Copy link

Morons commented Jan 27, 2021

can the onActivityResult Deprecated be fixed / updated!?

@Morons Morons changed the title onActivityResult depricted onActivityResult Deprecated Jan 27, 2021
@jasonsaruulo
Copy link

jasonsaruulo commented Jun 28, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants