Android loading local image with space in path and with universal image loader(Android使用路径中的空格和通用图像加载器加载本地图像)
问题描述
我正在开发 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();
我收到以下错误:
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/issues/371
Actually its problem with universal image loader. https://github.com/nostra13/Android-Universal-Image-Loader/issues/371
因此,您只需解码图像路径即可删除空间.
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);
这篇关于Android使用路径中的空格和通用图像加载器加载本地图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android使用路径中的空格和通用图像加载器加载本地图像
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
