码迷,mamicode.com
首页 > 移动开发 > 详细

with revoked permission android.permission.CAMERA

时间:2017-11-30 12:00:24      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:poi   相机   turn   res   point   stp   case   bsp   one   

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);
}
}
 

with revoked permission android.permission.CAMERA

标签:poi   相机   turn   res   point   stp   case   bsp   one   

原文地址:http://www.cnblogs.com/dubo-/p/7927821.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!