在使用GalleryFinal框架时,发现没有注册拍照权限竟然可以调用相机?
/**
* 拍照相关
*/
private void choosePhotoPop() {
PopManage.getCamera(this, include_action_bar, new KCallBack() {
@Override
public void getInt(int position) {
if (position == take_a_photo) {
PhotoManager.openCamera(getContext(), take_a_photo, null);
} else if (position == select_a_photo) {
PhotoManager.openGallerySingle(getContext(), select_a_photo, null);
}
}
});
}
Spickphotos框架使用
/**
* 拍照相关
*/
private void choosePhotoPop() {
PhotoPicker.Album(InfoManageActivity.this)
.setMultiChooseSize(1)
.setIsCompress(true)
.setIsCrop(true)
.setOnResultListener(new OnResultListener() {
@Override
public void onSucess(ArrayList<String> imagePathList) {
String a = "";
for (String path : imagePathList
) {
a += path;
}
Log.e("paths", a);
ImageLoader.newInstance().loadImageNativeFile(img_header, a);
}
@Override
public void onCancel() {
}
})
.start();
}
权限管理界面
于是乎我在项目中把拍照权限移除,运行程序,调用相机拍照抛出异常:file:///storage/emulated/0/xxx exposed beyond app through ClipData.Item.getUri
解决办法:
在Application的onCreat()方法中添加以下代码:
// android 7.0系统解决拍照的问题
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
网友评论