欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.con

程序员文章站 2022-03-30 08:55:10
...

问题描述

Samsung-G9287手机(android7.0系统),已经安装了google play store,已经给了权限。从相册读取图片时报错。

报错日志

2-22 12:03:37.106 22068-22068/? E/UriImage: createFromUri: content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F4397/ORIGINAL/NONE/1045177430
                                             java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord{683d6e3 22068:com.sec.android.gallery3d:crop/u0a50} (pid=22068, uid=10050) that is not exported from uid 10165
                                                 at android.os.Parcel.readException(Parcel.java:1693)
                                                 at android.os.Parcel.readException(Parcel.java:1646)
                                                 at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4878)
                                                 at android.app.ActivityThread.acquireProvider(ActivityThread.java:5949)
                                                 at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2470)
                                                 at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1521)
                                                 at android.content.ContentResolver.query(ContentResolver.java:520)
                                                 at android.content.ContentResolver.query(ContentResolver.java:478)
                                                 at com.sec.android.gallery3d.util.PerformanceAnalyzer.getCursor(PerformanceAnalyzer.java:39)
                                                 at com.sec.android.gallery3d.data.UriImage.getFilePathFromUri(UriImage.java:605)
                                                 at com.sec.android.gallery3d.data.UriImage.isDrm(UriImage.java:633)
                                                 at com.sec.android.gallery3d.data.UriImage.getSupportedOperations(UriImage.java:378)
                                                 at com.sec.android.gallery3d.app.CropImage.initializeData(CropImage.java:1664)
                                                 at com.sec.android.gallery3d.app.CropImage.onResume(CropImage.java:1713)
                                                 at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1277)
                                                 at android.app.Activity.performResume(Activity.java:7088)
                                                 at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3768)
                                                 at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3832)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2994)
                                                 at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:154)
                                                 at android.app.ActivityThread.main(ActivityThread.java:6682)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

解决方案

            case INTENT_SELECT:
                if (data != null && data.getData() != null) {
                    Uri imageUri = data.getData();
                    if (corp(activity, imageUri)) {
                    String filePath = getImageAbsolutePath(activity, imageUri);
                    File file = new File(filePath);
                    Uri realUri = Uri.fromFile(file);
                    if (corp(activity, realUri)) {
                        return;
                    }
                }

另外也可以参考下一个不错开源加载图像的工程https://github.com/crazycodeboy/TakePhoto