You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the Kotlin code sample as a basis and came up with the following:
askPermission(Manifest.permission.CALL_PHONE) { res ->
i { "all of your permissions have been accepted by the user: ${res.accepted}" }
i { "... and denied: ${res.denied}" }
val i =Intent(Intent.ACTION_CALL)
i.data =Uri.parse("tel:01234 56789")
startActivity(i)
}.onDeclined { e ->
i { "Permissions declined: ${e.denied}" }
i { "...and accepted: ${e.accepted}" }
}
I then called the function and chose to deny the permission. What I expected to happen was the bottom block to be called and the top to be untouched, what I actually saw is that both blocks get called - first the second, then the first. Here's the output:
I/Permissions declined: [android.permission.CALL_PHONE]
I/...and accepted: []
I/all of your permissions have been accepted by the user: []
I/... and denied: [android.permission.CALL_PHONE]
I solved the issue by modifying it somewhat:
askPermission(Manifest.permission.CALL_PHONE) { res ->
res.accepted.filter { it ==CALL_PHONE }.forEach {
i { "the ${res.accepted} permission has been accepted by the user" }
val i =Intent(Intent.ACTION_CALL)
i.data =Uri.parse("tel:01234 56789")
@Suppress("ConvertToStringTemplate")
startActivity(i)
}
}.onDeclined { e ->
i { "Permissions declined: ${e.denied}" }
}
Which works, but is not quite as elegant as the docs suggest it should be.
Also note the call to @Suppress("ConvertToStringTemplate") - this is to suppress the usual permissions lint error that we should try/catch a security exception. If there is any way this library can suppress that warning that would be ideal.
The text was updated successfully, but these errors were encountered:
I used the Kotlin code sample as a basis and came up with the following:
I then called the function and chose to deny the permission. What I expected to happen was the bottom block to be called and the top to be untouched, what I actually saw is that both blocks get called - first the second, then the first. Here's the output:
I solved the issue by modifying it somewhat:
Which works, but is not quite as elegant as the docs suggest it should be.
Also note the call to
@Suppress("ConvertToStringTemplate")
- this is to suppress the usual permissions lint error that we should try/catch a security exception. If there is any way this library can suppress that warning that would be ideal.The text was updated successfully, but these errors were encountered: