What is the use case for ContextCompat.checkSelfPermission?

戏子无情 提交于 2019-12-04 09:43:02

Depending on the implementation of the permission blocker (e.g. via Xposed) either the app is provided with fake data or the app's process will have the permission revoked.

You won't be able to detect whether the app gets fake data or not, but in that case your app will at least not crash.

If the permission is revoked on process level, then ContextCompat.checkSelfPermission() is able to detect it even on pre-M and returns PERMISSION_DENIED. Note that if you use the ContextCompat method you also have to use the ActivityCompat.shouldShowRequestPermissionRationale() and ActivityCompat.requestPermissions() methods or their FragmentCompat versions.

See here for more details: Support library methods for handling permissions.

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