-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Not work well with kotlin coroutine #719
Comments
thx for the report, could we possibly get a minimum example project to repro the issue? 🙏 |
a simple demo: fun FragmentActivity.pickPhoto() {
GlobalScope.launch {
catchAll {
requestSinglePermission(this@pickPhoto, Manifest.permission.CAMERA)
requestSinglePermission(
this@pickPhoto,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
// do works after granted
}
}
}
// make callback as coroutine API
suspend fun requestSinglePermission(fragmentActivity: FragmentActivity, vararg permissions: String): Boolean {
return suspendCancellableCoroutine {
fragmentActivity.constructPermissionsRequest(
*permissions,
onShowRationale = { it.proceed() },
onPermissionDenied = {
it.cancel()
},
onNeverAskAgain = {
it.cancel()
}
) {
if (it.isActive) {
it.resume(true)
}
}.launch()
}
} I don't know if it's possible to make this work. But what I really need is a parameter who can let me know witch permission(s) has been denied. |
thx, let us check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
I'm using the ktx library. Since I want to handle each type of permission denied event separately, I was trying to convert the callback API to coroutine and call every kind of permission request sequentially. Then I found that after the first coroutine executed and the request dialog was showed, the next coroutine will be inactive, and could not to resume, thus the future coroutines could not be execute.
I also found that when all the permissions was granted, the coroutine sequence could execute correctly. The only difference between the two cases is whether or not a permission request dialog pops up.
Expected
Permission request coroutine could run correctly.
Actual
After a permission request dialog was showed, the next coroutine will be inactive.
Environment
permissionsdispatcher-ktx:1.0.1
The text was updated successfully, but these errors were encountered: