我向我的应用添加了位置权限.现在安装应用程序时,它会询问用户权限.这是我的代码:
I added location permissions to my app. When installing the app now it asks the user for permission. This is my code:
if (fragment.shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION) { fragment.requestPermissions(....); }但是,当我安装了以前的应用程序版本时,我没有此位置权限并更新了该应用程序,则它不要求获得权限,例如
But when I have my previous app verison installed, where I didn't have this location permission and update the app then it does not ask for permission, as
fragment.shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION
返回 false
通常,仅当用户单击不再询问"时,这才应返回false.我在这里想念什么?
Normally this should only return false when the user clicked "never ask again". What am I missing here?
推荐答案shouldShowRequestPermissionRationale()也会返回false.这就是为什么理想的情况下,您首先要请求权限,然后通过 onRequestPermissionsResult 检查权限结果对象是什么,并在随后的所有请求之后检查 shouldShowRequestPermissionRationale()以查看是否用户已选中不再询问"选项.
shouldShowRequestPermissionRationale() also returns false if the user has never been asked for permission before. That's why ideally you first ask for permission, you then check what the permission result object is through onRequestPermissionsResult, and follow any consequent request with the check for shouldShowRequestPermissionRationale() to see whether the user has checked the never ask again option.
编辑-检查此答案中的示例: stackoverflow/a/34612503/10300673
EDIT- Check the example in this answer: stackoverflow/a/34612503/10300673
更多推荐
shouldShowRequestPermissionRationale为假
发布评论