Open taolulu opened 3 years ago
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
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