在路径和通用图像加载器空间机器人加载本地图像图像、加载、机器人、路径

2023-09-07 14:19:56 作者:警告警告您即将犯病请吃药

我正在开发中,我要与通用图像加载器的帮助下显示本地图像android应用。但是,当我尝试显示的图像具有的空间在里面的本地图片路径则无法显示图像。我试图在下列方式:

I am developing android application in which I want to display local image with the help of universal image loader. But when I try to display image which has space in it's local image path then it not able to display image. I tried it in following manner:

Uri.fromFile(new File(newImagePath)).toString();

我收到以下错误:

I am getting following error:

java.io.FileNotFoundException: /storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20150421-WA0002.jpg: open failed: ENOENT (No such file or directory)
        at libcore.io.IoBridge.open(IoBridge.java:456)

如果试图加载图像,在其本地路径没有空格那么它工作正常,但图像空间,其路径造成的问题。需要一些帮助。谢谢你。

If tried to load image which has no space in its local path then it works fine but image with space in its path cause issue. Need some help. Thank you.

推荐答案

其实它的问题与通用图像加载器。 https://github.com/nostra13/Android-Universal-Image-Loader /问题/ 371

Actually its problem with universal image loader. https://github.com/nostra13/Android-Universal-Image-Loader/issues/371

所以,你就必须去code图像路径中除去空间。

So you just have decode your image path to remove space.

按照上面的链接讨论中,我得到了解决:

As per discussion in above link I got the solution :

final String uri = Uri.fromFile(file).toString();
final String decoded = Uri.decode(uri);

ImageLoader.getInstance().displayImage(decoded, imageView);