Glide无法加载某些Android设备中从相机捕获的图像

问题描述 投票:0回答:1

在我的Android应用程序中,我从相机捕获图像并加载滑动。在某些设备中,它工作正常,但有些设备如LG Q6,MI注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" />
android android-imageview android-glide android-image-capture
1个回答
1
投票

您的图片地址不在app文件目录中,因此您必须确保拥有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);
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.