Android选择头像

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("当前应用缺少相应的权限,请点击'设置-权限'打卡所需权限");
}
});

}
原文地址:https://www.cnblogs.com/kim-liu/p/7783034.html