【问题标题】:UIL: load image from external storageUIL:从外部存储加载图像
【发布时间】:2014-07-20 22:59:54
【问题描述】:

您好,我正在尝试使用 UIL 和以下 uri 从本机操作系统库加载图像:

/storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg

我得到了:

UIL doesn't support scheme(protocol) by default [/storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
    java.lang.UnsupportedOperationException: UIL doesn't support scheme(protocol) by default [/storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))

任何建议我如何加载这样的图像?

【问题讨论】:

标签: android universal-image-loader


【解决方案1】:

在 UIL 中,如果您从 SDCARD 加载图像,您应该使用前缀 file:/// 作为

  String imageUri = "file:///mnt/sdcard/image.png"; // from SD card

 "file:///"+Environment.getExternalStorageDirectory().toString()
                + File.separator + "image.png";

所以使用图片路径作为

file:///storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg

【讨论】:

  • 已经试过了,得到:无法解码流:java.io.FileNotFoundException:/file:/storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg:打开失败:ENOENT(没有这个文件或目录)07-21 09:55:15.850 22038-22662/com.autodesk.autocad360.cad.staging D/Sean9: getCurrentHub, mCurrentHub null?假
  • @EvgeniRoitburg 你添加了权限“
  • @EvgeniRoitburg 尝试附加“file:///”而不是“file:/”
  • 我正在发送“file:///+ 路径”,我认为它在打印到日志时以某种方式发生了变化
  • @EvgeniRoitburg 尝试发送完整路径,例如“file:///storage/emulated/0/DCIM/Camera/IMG_20140713_103602.jpg”
【解决方案2】:

试试下面的格式,

String imageUri = "file:///mnt/sdcard/image.png"; // from SD card

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    • 2020-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多