我正在练习将谷歌地图API与Android集成。
当我试图获得的权限时
Manifest.permission.ACCESS_FINE_LOCATION
和Manifest.permission.ACCESS_COARSE_LOCATION
,对Manifest.permission.ACCESS_COARSE_LOCATION
的权限被拒绝。但是,已授予Manifest.permission.ACCESS_FINE_LOCATION
的权限。我想知道Manifest.permission.ACCESS_COARSE_LOCATION
被拒绝的原因。感谢您的帮助。
创造这种乐趣(Kotlin(
fun setupPermissions(context:Context,activity: Activity,permission: String, requestCode: Int) {
if (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_DENIED) {
// Requesting the permission
ActivityCompat.requestPermissions(activity, arrayOf(permission), requestCode)
return
}
}
之后呼叫
setupPermissions(requireContext(),requireActivity(),*CAMERA*,234)