with revoked permission android.permission.CAMERA
1,刚出现这样的问题我是直接把 CAMERA 移除掉
2.第一步判断时候授权。
if (Build.VERSION.SDK_INT >= 23) {
int checkCallPhonePermission = ContextCompat.checkSelfPermission(AppointmentDetailActivity.this, Manifest.permission.CAMERA);
if(checkCallPhonePermission != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(AppointmentDetailActivity.this,new String[]{Manifest.permission.CAMERA},OPEN_CANMER);
return;
}else{
showCamera();
}
} else {
showCamera();
}
第二步 接收返回的结果。
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case OPEN_CANMER:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showCamera();
} else {
Toast.makeText(AppointmentDetailActivity.this, "相机权限禁用了。请务必开启相机权", Toast.LENGTH_SHORT).show();
}
break;
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步