【问题标题】:Glide couldn't load image that is capturing from camera in some android devicesGlide 无法加载从某些 Android 设备中的摄像头捕获的图像
【发布时间】:2018-09-21 13:43:24
【问题描述】:

在我的 android 应用程序中,我正在从相机捕获图像并通过滑行加载它。在某些设备中它可以正常工作,但某些设备(如 LG Q6、MI note 4)无法正常加载。请检查我的代码并给出一些解决方案。

在 Kotlin 文件中:

val imageURL = "/storage/emulated/0/Pictures/1537536635333.jpg"
Glide.with(activity!!)
     .load(imageURL)
     .into(cameraThumbnailIV)

在 XML 文件中:

<ImageView
        android:id="@+id/cameraThumbnailIV"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:scaleType="centerCrop"
        android:src="@drawable/photothumbnail" />

【问题讨论】:

  • It doesn't load properly 这是什么意思?它根本不加载,应用程序崩溃或部分加载?
  • 它没有加载。如果我将 .error 与图像放在一起,它将以 .error 方法显示该图像。 @lonut j。贝让
  • 检查是否给出了READ_EXTERNAL_STORAGE

标签: android android-imageview android-glide android-image-capture


【解决方案1】:

您的图片地址不在应用文件目录中,因此您必须确保拥有READ_EXTERNAL_STORAGE 才能让 Glide 读取图片。

您还可以启用 Glide 日志记录以找出罪魁祸首:

public class GlideModule extends AppGlideModule {    
    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
        // Apply options to the builder here.
       builder.setLogLevel(Log.ERROR);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-09
    • 2013-01-18
    相关资源
    最近更新 更多