shouldShowRequestPermissionRationale is false

℡╲_俬逩灬. 提交于 2021-01-27 21:07:47

问题


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

returns false

Normally this should only return false when the user clicked "never ask again". What am I missing here?


回答1:


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.

EDIT- Check the example in this answer: https://stackoverflow.com/a/34612503/10300673



来源:https://stackoverflow.com/questions/55066714/shouldshowrequestpermissionrationale-is-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!