Android tricks – Runtime permissions and the ‘Never ask again’ option

With Android 6.0 (API 23) users are able to grant app permissions during run time. That new feature made our developer lives a bit more difficult, but gave huge powers to our users. And do you remember that little check box which says ‘Never ask me again’?

Yep… this particular one! So, how can we know that this check box had ever been selected by the user? Actually, it’s not that difficult! There is a method called shouldShowRequestPermissionRationale . This method has a boolean return type. It returns:

  • true – if the app has requested this permission previously and the user denied it without selecting the ‘Never ask me again’ checkbox
  • false – if the permission was denied together with the checkbox being checked

So, if this method returns false , then we can be sure that the checkbox was selected and we can show a dialog to the user and navigate him / her to the phone settings where he / she can enable that permission.

Sadly, as of this date, the official Android documentation for this method does not represent the reality. Right now, this method accepts only the String parameter. The Activity parameter is currently missing.

Resources:

https://stackoverflow.com/questions/30719047/android-m-check-runtime-permission-how-to-determine-if-the-user-checked-nev

Feel free to share, comment & give your opinion on the topic!

And only if you really REALLY liked the article, you can buy me a cup of coffee! Otherwise, don’t do it! Donate $1

稿源:Spot Android (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » Android tricks – Runtime permissions and the ‘Never ask again’ option

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录