关于android6.0运行时权限(定位)

//安卓系统大于6.0为运行时权限,需要在运行时得到用户的授权
        if (Build.VERSION.SDK_INT >= 23) {
            //启动服务
            if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                    && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
                ActivityCompat.requestPermissions(this, permissions, 1);
            }
        }

你可能感兴趣的:(关于android6.0运行时权限(定位))