Blankj / AndroidUtilCode

:fire: Android developers should collect the following utils(updating).
https://blankj.com/2016/07/31/android-utils-code/
Apache License 2.0
33.35k stars 10.69k forks source link

Android 11 PermissionUtils.permission(PermissionConstants.LOCATION) 定位权限一直onDenied #1578

Open zlpyab opened 2 years ago

zlpyab commented 2 years ago

com.blankj:utilcodex:1.30.6 在Android11 上(小米、oppo)

PermissionUtils.permission(PermissionConstants.LOCATION) .callback(object : PermissionUtils.SimpleCallback { override fun onGranted() { } override fun onDenied() { } }).request()

总是直接回调onDenied(),没有弹请求权限框,直接回调onDenied()

经测试,在android11、targetSdkVersion>=30上不能同时请求ACCESS_FINE_LOCATION、ACCESS_COARSE_LOCATION、ACCESS_BACKGROUND_LOCATION 权限,应先请求前台位置权限,再请求后台位置权限,请求前台位置权限的同时加上后台权限,请求权限弹框会一闪而过不会弹起

在android11、targetSdkVersion<=29 上正常

XaviaDev commented 2 years ago

I have the same problem, did you find the solution?