[英]Unable to load imageView using nostra13 Universal Image loader android .
Hi all I am trying to display an image using UniversalImageLoader by nostra13. 大家好,我正在尝试使用nostra13的UniversalImageLoader显示图像。 I have no idea how to get the failReason.
我不知道如何获取failReason。 This is my code to load an image uri.
这是我的代码加载图像uri。 I am using de.hdodenhof.circleimageview.CircleImageView for this.
我为此使用de.hdodenhof.circleimageview.CircleImageView。
CircleImageView profilePhoto = findViewById(R.id.profile_photo);
imageLoader.displayImage(user.getImage_path(),profilePhoto,new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
Log.i(TAG,"started");
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.i(TAG,imageUri);
failReason.getCause();
Log.i(TAG,failReason.getType().toString());
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
Log.i(TAG,"YAY");
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
The String image Uri is a content provider uri as I am trying to load this image from my phone's storage. 字符串图像Uri是内容提供商uri,因为我正尝试从手机的存储设备加载该图像。
imageUri : content://com.android.providers.media.documents/document/image%3A38
As I know Universal Image Loader is able to load content provider Uri. 据我所知,Universal Image Loader能够加载内容提供商Uri。 I am not sure how to view the error also.
我也不确定如何查看错误。 Any help is appreciated :)
任何帮助表示赞赏:)
All right so I figured it out after sieving through the logs I was getting a Security exception 好的,所以我在筛选日志后发现了安全异常
java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{500992e 4972:com.example.recouture/u0a83} (pid=4972, uid=10083) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
because what I did was I chose a image from gallery in another activity and uploaded that uri to firebase. 因为我所做的是我在另一个活动中从画廊中选择了一幅图像,并将该uri上传到firebase。 So in another activity, I was going to read the uri from firebase and set it to a image in the current activity I am in. However , my current activity did not have the required permissions to do it even though the activity I uploaded the uri did.
因此,在另一个活动中,我将从firebase中读取uri,并将其设置为当前所在活动中的映像。但是,即使我上传了uri,当前活动也没有执行此操作所需的权限没有。 What I did to circumvent this issue was to upload the image using firebase storage and store the uri into the object I am uploading to firebase.
为了避免这个问题,我要做的就是使用Firebase存储上传图像并将uri存储到我要上传到Firebase的对象中。 Then in the activity that I want to retrieve the Uri, I can easily use ImageLoader to display the uri from firebase.
然后在要检索Uri的活动中,我可以轻松地使用ImageLoader从firebase中显示uri。 Sorry for not posting all the code as I didn't think that I would come across such error.
对不起,我没有发布所有代码,因为我不认为会遇到此类错误。 Hope this helps someone.
希望这对某人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.