问题描述
在我的应用程序中使用的通用图像下载BaseImageDownloader类gallery.For的syncronious加载内容来自Imageloader.getInstance相同的内容()。的LoadImage asyncronious功能,它不提供任何安全性异常并加载图像,因为它是彪是,但是当我尝试syncroniously使用BaseImageDownloader下载(也Imageloader.getInstance()的LoadImage()作出了同样的)我得到这个安全例外
09-02 18:49:43.971:W / System.err的(4244):java.lang.SecurityException异常:权限被拒绝:阅读com.android.gallery3d.provider.GalleryProvider URI内容://com.google.android.gallery3d.provider/picasa/item/5879964074642783474从PID = 4244,UID = 10064要求com.google.android.gallery3d.permission.GALLERY_PROVIDER,或grantUriPermission()
09-02 18:49:43.971:W / System.err的(4244):在android.os.Parcel.readException(Parcel.java:1425)
09-02 18:49:43.971:W / System.err的(4244):在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
09-02 18:49:43.971:W / System.err的(4244):在android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:148)
09-02 18:49:43.971:W / System.err的(4244):在android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:617)
09-02 18:49:43.971:W / System.err的(4244):在android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:717)
09-02 18:49:44.011:W / System.err的(4244):在android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
09-02 18:49:44.011:W / System.err的(4244):在android.content.ContentResolver.openInputStream(ContentResolver.java:449)
09-02 18:49:44.011:W / System.err的(4244):在com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromContent(BaseImageDownloader.java:156)
09-02 18:49:44.011:W / System.err的(4244):在com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
09-02 18:49:44.011:W / System.err的(4244):在com.uploader.data.UploadImageData.de codeSampledBitmapFromStream(UploadImageData.java:80)
此外,我找遍了code和你不采取任何权限上配置或其他地方会是什么原因呢?
公共位图德codeSampledBitmapFromStream(字符串路径,INT reqWidth,诠释reqHeight)抛出IOException异常{
BaseImageDownloader下载=新BaseImageDownloader(getApplicationContext());
InputStream的流= downloader.getStream(路径,NULL);
最后BitmapFactory.Options选项=新BitmapFactory.Options();
options.inJustDe codeBounds = TRUE;
BitmapFactory.de codeStream(流,新的矩形(-1,-1,-1,-1),选件);
stream.close();
options.inSampleSize = calculateInSampleSize(选项,reqWidth,reqHeight);
options.inJustDe codeBounds = FALSE;
流= downloader.getStream(路径,NULL);
点阵位图= BitmapFactory.de codeStream(流,新的矩形(-1,-1,-1,-1),选件);
stream.close();
返回的位图;
}
我添加权限mainfest和它的工作。但我不知道如何UIL使没有这种??
<使用-权限的Android:名称=com.google.android.gallery3d.permission.GALLERY_PROVIDER/>
On my application I used universal image downloader BaseImageDownloader class for syncronious loading contents of gallery.For the same content from Imageloader.getInstance().loadImage asyncronious function it does not gives any security exception and loads the image as it is ment to be but when I try to download it syncroniously using BaseImageDownloader (Also Imageloader.getInstance().loadImage() makes the same) i get this security Exception
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)
Also I searched the code and you do not take any permission for that on configuration or somewhere else what will be the cause?
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;
}
I added permission to mainfest and it worked. But I dont know How UIL makes without that??
<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER"/>
这篇关于SecurityException异常下载与通用,图片,下载图像时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!