Android检查相机或日历等授权情况

检查权限是否授权

//检查日历 Manifest.permission.WRITE_CALENDAR

//日历读写是否授权
//依赖 import androidx.core.app.ActivityCompat;
//getActivity()为 Activity.this

Boolean flag = false;
//如果是MainActivity 将getActivity()改为MainActivity.this
if ((ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED)&&(ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED)) {
	flag = false;
}else{
	flag = true;
}

//检查相机 Manifest.permission.CAMERA

if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
	return false;
}
	return true;

如果安卓相机|日历等权限授权请看下方连接
https://blog.csdn.net/mingketao/article/details/121356861

你可能感兴趣的:(个人日志,android)