当前位置:网站首页>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).....
}
边栏推荐
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- adb push apk
- Nodejs+Express+MySQL实现登陆功能(含验证码)
- Solve the problem of VI opening files with ^m at the end
- Cloud Computing future - native Cloud
- Lambda表达式
- TOGAF认证自学宝典V2.0
- elastic_ L01_ summary
- ORM use of node -serialize
猜你喜欢

GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈

雲計算未來 — 雲原生

剑指Offer04. 二维数组中的查找【中等】

Record your vulnhub breakthrough record

低代码平台国际化多语言(i18n)技术方案

Xctf mobile--app3 problem solving

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

If you can't learn, you have to learn. Jetpack compose writes an im app (I)

Swift bit operation exercise

Eureka self protection
随机推荐
Unicode查询的官方网站
Implement verification code verification
Eureka自我保护
Xctf mobile--app1 problem solving
Sword finger offer10- I. Fibonacci sequence
Write a simple nodejs script
Airflow installation jump pit
How to convert a decimal number to binary in swift
2021 autumn Information Security Experiment 1 (password and hiding technology)
Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
The future of cloud computing cloud native
Sword finger offer09 Implementing queues with two stacks
剑指Offer09. 用两个栈实现队列
电压环对 PFC 系统性能影响分析
剑指Offer06. 从尾到头打印链表
2.9 overview of databinding knowledge points
[embedded] - Introduction to four memory areas
Swift bit operation exercise
Node.js: express + MySQL的使用
【嵌入式】---- 内存四区介绍