欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Android 使用Glide 报You cannot start a load for a destroyed activity异常

程序员文章站 2022-05-04 07:50:40
...
Fatal Exception: java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity
       at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:134)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:102)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:87)
       at com.bumptech.glide.Glide.with(Glide.java:620)
       at com.myapp.myapp$24.run(MyAppClass.java:977)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5431)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)

最简单的解决方式

try{
	GlideApp.with(this).load(imgurl).apply(RequestOptions.bitmapTransform(new CircleCrop())).error(R.drawable.error_icon).into(imageview);
}catch (Exception e){
	e.printStackTrace();
}

参考: https://github.com/bumptech/glide/issues/803

https://blog.csdn.net/qq_34650238/article/details/79976297

https://blog.csdn.net/guolin_blog/article/details/53939176

相关标签: 安卓知识