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

上一篇 Android 5.0以下Glide加载https图片问题
下一篇 Android接入Google Play Service
目录
文章列表
1 前端接收后端文件流并下载的几种方法
前端接收后端文件流并下载的几种方法
2
Android NDK 版本选择
Android NDK 版本选择
3
CentOS 7 利用crontab定时执行任务
CentOS 7 利用crontab定时执行任务
4
Vuex的actions传递多个参数
Vuex的actions传递多个参数
5
Spring Security Oauth2 中优雅的扩展自定义(短信验证码)登录方式
Spring Security Oauth2 中优雅的扩展自定义(短信验证码)登录方式
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。