是否可以在最小SDK<上设置checkSelfPermission? 23? [英] Is it available to set checkSelfPermission on minimum SDK < 23?
问题描述
Android-M中的新运行时权限要求最低23个API级别,但我的项目中仍需要最低16 API级别.
New runtime permissions in Android-M asking for minimum 23 API level, but I still need minimum 16 API level in my project.
那么,如何使此代码更向前兼容?
So, how to make this code more forward-compatible?
致谢
推荐答案
ActivityCompat.requestPermissions()
和ContextCompat.checkSelfPermission()返回PackageManager.PERMISSION_GRANTED
).
Use ContextCompat.checkSelfPermission()
, ActivityCompat.requestPermissions()
, and ActivityCompat.shouldShowPermissionRequestRationale()
, from the support-v4
library (v23 or higher). These are backwards-compatible; if you are running on an older version of Android, they will "do the right thing" (e.g., return PackageManager.PERMISSION_GRANTED
for ContextCompat.checkSelfPermission()
).
这篇关于是否可以在最小SDK<上设置checkSelfPermission? 23?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!