Glide错误IllegalArgumentException You cannot start a load for a destroyed activity

问题描述

Glide在Activity或Fragment销毁destroy时报错:

java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity

解决办法

使用Glide加载图片时判断context是否为空、或使用ApplicationContext、或判断当前Activity是否被销毁

if (context !=null) {
    mGlideRequest = Glide.with(context).load(url).placeholder(R.drawable.default_img).dontAnimate().error(R.drawable.error_img);
}
Glide.with(getActivity().getApplicationContext())

原issue地址:https://github.com/bumptech/glide/issues/803
参考: https://stackoverflow.com/questions/31964737/glide-image-loading-with-application-context/32887693#32887693
参考:https://stackoverflow.com/questions/39093730/you-cannot-start-a-load-for-a-destroyed-activity-in-relativelayout-image-using-glide

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/18/glide-error-illegalargumentexception-you-cannot-start-a-load-for-a-destroyed-activity/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Glide错误IllegalArgumentException You cannot start a load for a destroyed activity
问题描述 Glide在Activity或Fragment销毁destroy时报错: java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity 解决办法……
<<上一篇
下一篇>>
文章目录
关闭
目 录