//动态访问权限弹窗
public Boolean checkPermission() {
boolean isGranted = true;
if (android.os.Build.VERSION.SDK_INT >= 23) {
if (this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
isGranted = false;
}
if (this.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) !=PackageManager.PERMISSION_GRANTED) {
isGranted = false;
}
Log.i("读写权限获取"," : "+isGranted);
if (!isGranted) {
this.requestPermissions(
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission
.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE},
102);
}
}
return isGranted;
}
转自:https://www.cnblogs.com/xfweb/p/14460216.html