当前位置:网站首页>Glide question you cannot start a load for a destroyed activity
Glide question you cannot start a load for a destroyed activity
2022-07-03 12:44:00 【liuhaha1015】
Basic use :
Glide.with(context).load(imageUrl).into(imageView);
appear “You cannot start a load for a destroyed activity” The scene is :
Like when the third-party server requests pictures , In the process of requesting the network , Shut down the activity, Will report this error .
as a result of :
The main reason is that context On , Because although it is closed activity, But after the successful callback of the network comes back , Get the picture address , Reuse glide When loading images ,activity It has been finish 了 ~
see glide Source code :
Then throw an exception here :
Is that when activity.isDestroyed() When This anomaly will occur ~
There are also several other exceptions :
You cannot start a load on a fragment before it is attached
You cannot start a load on a null Context
In the final analysis, it is because we have introduced a destroyed Activity Or an empty one Context ,Fragment Mounted Activity Caused by emptiness
Review the scenarios used , It is called after the successful callback Glide When executed Glide.with(); When the method is used , Current Activity It has been destroyed , That's why this problem .
The solution is :
In the use of activity When parameters are passed ,
if(!this.isFinishing()) {
Glide.with(this).....
}
or
if(!this.isDestroyed()) {
Glide.with(this).....
}
When using context When parameters are passed ,
if(context !=null) {
Glide.with(context).....
}
When using fragment When parameters are passed ,
if (fragment != null && fragment.getActivity() != null) {
Glide.with(fragment).....
}
边栏推荐
- elastic_ L01_ summary
- 低代码平台国际化多语言(i18n)技术方案
- Apache Mina Development Manual
- Analysis of a music player Login Protocol
- Do you feel like you've learned something and forgotten it?
- Xctf mobile--app1 problem solving
- 2021 autumn Information Security Experiment 1 (password and hiding technology)
- 2020-11_ Technical experience set
- Fundamentals of concurrent programming (III)
- ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
猜你喜欢
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
剑指Offer06. 从尾到头打印链表
Alibaba is bigger than sending SMS (user microservice - message microservice)
Sword finger offer07 Rebuild binary tree
Sword finger offer10- I. Fibonacci sequence
If you can't learn, you have to learn. Jetpack compose writes an im app (I)
阿里 & 蚂蚁自研 IDE
社交社区论坛APP超高颜值UI界面
Day 1 of kotlin learning: simple built-in types of kotlin
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
随机推荐
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
2020-09_ Shell Programming Notes
lambda与匿名内部类的区别
并网-低电压穿越与孤岛并存分析
Kubectl_ Command experience set
公纵号发送提示信息(用户微服务--消息微服务)
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
Sword finger offer10- I. Fibonacci sequence
CNN MNIST handwriting recognition
Xctf mobile--rememberother problem solving
Comprehensive evaluation of double chain notes · Siyuan notes: advantages, disadvantages and evaluation
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
雲計算未來 — 雲原生
Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
Prompt unread messages and quantity before opening chat group
JVM memory model
Sword finger offer07 Rebuild binary tree
Lambda expression
Xctf mobile--app3 problem solving
Official website of Unicode query