Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord #15

Closed
2639117470 opened this issue Jan 22, 2017 · 1 comment

Comments

@2639117470
Copy link

5.0以上的系统没问题,4.0的系统上,报上述错误;
GalleryPickActivity.java的showCameraAction()函数,修改一下:
private void showCameraAction() {
// 跳转到系统照相机
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(mActivity.getPackageManager()) != null) {
// 设置系统相机拍照后的输出路径
// 创建临时文件
cameraTempFile = FileUtils.createTmpFile(mActivity, galleryConfig.getFilePath());
Uri imageUri = FileProvider.getUriForFile(mContext, "com.yancy.gallerypick.fileprovider", cameraTempFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);

        List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY);
        for (ResolveInfo resolveInfo : resInfoList) {
            String packageName = resolveInfo.activityInfo.packageName;
            mContext.grantUriPermission(packageName, imageUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }

        startActivityForResult(cameraIntent, REQUEST_CAMERA);
    } else {
        Toast.makeText(mContext, R.string.gallery_msg_no_camera, Toast.LENGTH_SHORT).show();
        galleryConfig.getIHandlerCallBack().onError();
    }
}
@YancyYe
Copy link
Owner

YancyYe commented Feb 3, 2017

感谢反馈,,, 已经修改此bug 稍作整理 会发布下个版本

@YancyYe YancyYe closed this as completed Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants