好吧,我有在如下面的代码和警告: Android Studio添加权限检查错误?
当我同意添加此类检查,AS插入下面的代码:
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return TODO;
}
而我只是想知道,为什么AND运算符正在使用?
如果用户只拒绝上面的权限之一,那么这样的检查将不起作用,就像我一样。
还是我想念什么?
好吧,所以Android Studio添加的权限检查是错误的?在这种情况下,应该有OR运算符而不是AND。 –