我正在为地图生成一个项目并检查我尝试使用的权限,如果对ContextCompat.checkSelfPermission
的声明与工作室不接受
我的代码如下:
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
if (ContextCompat.checkSelfPermission(this,getApplicationContext(),FINE_LOCATION)==
PackageManager.PERMISSION_GRANTED){
任何建议?
答案 0 :(得分:0)
确保从Manifest
import 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){
现在它会起作用。谢谢!