guolindev / PermissionX

An open source Android library that makes handling runtime permissions extremely easy.
Apache License 2.0
3.34k stars 386 forks source link

申请 SYSTEM_ALERT_WINDOW 权限直接回调到拒绝授权 #239

Open Zackratos opened 1 year ago

Zackratos commented 1 year ago

如题,代码如下

PermissionX.init(fragment)
    .permissions(Manifest.permission.SYSTEM_ALERT_WINDOW)
    .request {allGranted, _, _ ->
        if (allGranted) {
            hideTips()
        }
    }

执行之后无法打开授权页面,而是直接回调到 RequestCallback.onResult 方法里,并且 allGranted == false,但是如果在中间加上

.onExplainRequestReason { scope, deniedList, beforeRequest ->
    val message = "PermissionX needs following permissions to continue"
    scope.showRequestReasonDialog(deniedList, message, "Allow", "Deny")
}

点击 “Allow” 就可以打开授权页面了