-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Case when permission is canceled was not handled #125
Comments
Since this cancelation behavior is quite rare, I suggest to add a callback too when |
I'm unable to get empty BTW, what is the permission name that you're using on the screenshot? |
@anggrayudi I am using camera permission inside Fragment.
My hypothesis is, the cancelation happened when you request permission while requesting permission.
|
Yes, I can reproduce it too, by using this snippet: private val cameraPermissionRequest = FragmentPermissionRequest.Builder(this)
.withPermissions(Manifest.permission.CAMERA)
.withCallback(object : PermissionCallback {
override fun onPermissionsChecked(result: PermissionResult, fromSystemDialog: Boolean) {
Toast.makeText(requireContext(), result.areAllPermissionsGranted.toString(), Toast.LENGTH_SHORT).show()
}
})
.build()
@SuppressLint("NewApi")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
btnRequestCamera.setOnClickListener {
cameraPermissionRequest.check()
it.handler.postDelayed({
// this will trigger empty "result"
cameraPermissionRequest.check()
}, 5000L)
} |
Released v1.5.5, and I've added |
Library version: 1.4.0
OS version: Android 13
Device model: Redmi Note 10 Pro
Describe the bug
Based on this documentation: https://developer.android.com/training/permissions/requesting#manage-request-code-yourself
There are certain cases where the permission interaction is canceled, resulting empty result.
When cancelation occured and returns empty result, the
callback.onPermissionChecked()
(callback for granted permission) was called. This is unexpected (or at least isn't quite right) because no permisison is granted, yet the callback for granted permission is triggered.To Reproduce
I don't have the steps to reproduce it, but hope this screenshot when I debug it will help
In that screenshot, the result is empty and the
callback.onPermissionChecked()
block code is executedThe text was updated successfully, but these errors were encountered: