Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 访问精细位置的运行时权限_Android_Permissions_Maps - Fatal编程技术网

Android 访问精细位置的运行时权限

Android 访问精细位置的运行时权限,android,permissions,maps,Android,Permissions,Maps,我正在为maps生成一个项目,并检查我试图对ContextCompat使用if语句的权限。studio不接受checkSelfPermission 我的代码如下: private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION; if (ContextCompat.checkSelfPermission(this,getApplicationContext(),FINE_LOCATION)

我正在为maps生成一个项目,并检查我试图对
ContextCompat使用if语句的权限。studio不接受checkSelfPermission

我的代码如下:

private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;

if (ContextCompat.checkSelfPermission(this,getApplicationContext(),FINE_LOCATION)==
          PackageManager.PERMISSION_GRANTED){

有什么建议吗?

确保下一行中的
清单是从
导入android.Manifest导入的

 private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
改变这个

if (ContextCompat.checkSelfPermission(this,getApplicationContext(),FINE_LOCATION)==
          PackageManager.PERMISSION_GRANTED){

现在可以了,谢谢

if (ContextCompat.checkSelfPermission(this,FINE_LOCATION)==
                    PackageManager.PERMISSION_GRANTED){