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

问题描述

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

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

解决办法

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

1
2
3
if (context !=null) {
mGlideRequest = Glide.with(context).load(url).placeholder(R.drawable.default_img).dontAnimate().error(R.drawable.error_img);
}
1
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

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :