http://www.jianshu.com/p/8b3e78046c1c

 

注意:在Android6.0之后,使用相机拍照需要权限

在选择头像使用相机拍摄时添加以下代码即可。

 Acp.getInstance(mActivity).request(new AcpOptions.Builder().setPermissions(
Manifest.permission.CAMERA).build(), new AcpListener() {
@Override public void onGranted() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(mActivity.getPackageManager()) != null) {
// 创建文件来保存拍的照片
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// 异常处理
}
if (photoFile != null) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
} else {
tip("无法启动相机");
}
}

@Override public void onDenied(List<String> permissions) {
tip("当前应用缺少相应的权限,请点击'设置-权限'打卡所需权限");
}
});

}

相关文章:

  • 2021-08-14
  • 2021-11-14
  • 2022-12-23
  • 2022-01-16
  • 2021-09-09
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-01-21
  • 2021-06-04
  • 2022-12-23
相关资源
相似解决方案