这个崩溃的详细原因:
Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE cmp=com.meizu.media.camera/.CameraActivity } from ProcessRecord{6933b01 31104:com.iflytek.wsagvideo/u0a358} (pid=31104, uid=10358) with revoked permission android.permission.CAMERA
解决方案
该异常表示权限不允许。
[解决方案]:该问题的原因是没有声明对应的权限,解决该问题的方法如下
1.android6.0以下需要在manifest中声明相应的权限;
2.android6.0及以上,在使用时需要动态申请权限
在使用app过程中(6.0系统以上的手机)用户拒绝了某种危险权限(可能侵犯到隐私的权限),在用到这种权限功能的时候造成了这种异常
解决方法:
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(android.Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
Log.d(TAG,"Permission is granted");
//有权限,正常操作
return true;
} else {
//重新请求权限
Log.d(TAG,"Permission is revoked");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1);
return false;
}
}
else { //permission is automatically granted on sdk<23 upon installation
Log.d(TAG,"Permission is granted");
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if(grantResults[0]== PackageManager.CAMERA){
Log.d(TAG,"Permission: "+permissions[0]+ "was "+grantResults[0]);
//resume tasks needing this permission
}
}