Android M - anyway to know if a user has chosen never to show the grant permissions dialog ever again?

后端 未结 1 1981
萌比男神i
萌比男神i 2021-01-28 23:32

If an all calls ActivityCompat.requestPermissions() then the OS displays a dialog with Deny or Permit buttons. There is also a never show this again tick box.

However th

相关标签:
1条回答
  • 2021-01-28 23:42

    You can use ActivityCompat.shouldShowRequestPermissionRationale() - it will return false in a few cases:

    • You've never asked for the permission before
    • The user has checked the 'never again' checkbox
    • The permission has been disabled by policy (say, in a work situation)

    By combining this with a shared preference to store if you've ever asked for permission, you can effectively determine if they'll actually see the dialog when you call requestPermissions().

    0 讨论(0)
提交回复
热议问题