小编典典

使用Universal-Image-Downloader下载图像时出现SecurityException

java

在我的应用程序上,我使用通用的图像下载器BaseImageDownloader类同步加载画廊的内容。对于来自Imageloader.getInstance()。loadImage异步函数的相同内容,它不会给出任何安全异常并按原样加载图像,但是当我尝试使用BaseImageDownloader同步下载它(而且Imageloader.getInstance()。loadImage()相同),我得到了此安全异常

09-02 18:49:43.971: W/System.err(4244): java.lang.SecurityException: Permission Denial: reading com.android.gallery3d.provider.GalleryProvider uri content://com.google.android.gallery3d.provider/picasa/item/5879964074642783474 from pid=4244, uid=10064 requires com.google.android.gallery3d.permission.GALLERY_PROVIDER, or grantUriPermission()
09-02 18:49:43.971: W/System.err(4244):     at android.os.Parcel.readException(Parcel.java:1425)
09-02 18:49:43.971: W/System.err(4244):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
09-02 18:49:43.971: W/System.err(4244):     at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:148)
09-02 18:49:43.971: W/System.err(4244):     at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:617)
09-02 18:49:43.971: W/System.err(4244):     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:717)
09-02 18:49:44.011: W/System.err(4244):     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
09-02 18:49:44.011: W/System.err(4244):     at android.content.ContentResolver.openInputStream(ContentResolver.java:449)
09-02 18:49:44.011: W/System.err(4244):     at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromContent(BaseImageDownloader.java:156)
09-02 18:49:44.011: W/System.err(4244):     at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
09-02 18:49:44.011: W/System.err(4244):     at com.uploader.data.UploadImageData.decodeSampledBitmapFromStream(UploadImageData.java:80)

我也搜索了代码,但您对配置或其他地方没有任何许可,这是什么原因?

public Bitmap decodeSampledBitmapFromStream(String path, int reqWidth, int reqHeight) throws IOException {
        BaseImageDownloader downloader = new BaseImageDownloader(getApplicationContext());
        InputStream stream = downloader.getStream(path, null);
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(stream, new Rect(-1,-1,-1,-1), options);
        stream.close();
        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

        options.inJustDecodeBounds = false;
        stream = downloader.getStream(path, null);
        Bitmap bitmap = BitmapFactory.decodeStream(stream, new Rect(-1,-1,-1,-1), options);
        stream.close();
        return bitmap;
    }

阅读 264

收藏
2020-11-26

共1个答案

小编典典

我向mainfest添加了权限,并且它起作用了。但是我不知道没有它,UIL是如何制造的?

<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER"/>
2020-11-26