博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android 图片异步加载 线程的问题
阅读量:2384 次
发布时间:2019-05-10

本文共 845 字,大约阅读时间需要 2 分钟。

弱引用,传入ImageView解决

Note how we use a  to hold onto the ImageView. When the user shuts down the application or simply rotates the device the current Activity is closed and/or restarted. The previous Activity can not be disposed of while we are still holding references to it, so we are facing a potential memory leak. The most common solution to this problem is to use a WeakReference when holding onto the parent Activity. An object referenced by a weak reference can still be garbage collected when no other soft or weak reference points to it. Once we have lost the reference to the previous Activity, it is the responsibility of the new parent Activity to re-inject the target View/Activity for our image. To get further help one could use the  class, which helps in surviving the Activity switch.

转载于:https://my.oschina.net/u/942328/blog/207935

你可能感兴趣的文章
PHP单例模式应用详解
查看>>
冒号课堂§5.2:数据类型
查看>>
博客搬家
查看>>
冒号课堂§6.2:平台语言
查看>>
《关于信息系统组织方式的一个提案》的评论与反评
查看>>
冒号和他的学生们(连载10)——超级范式
查看>>
冒号和他的学生们(连载9)——泛型范式
查看>>
冒号和他的学生们(连载13)——范式总结
查看>>
A Proposal on Organization of Information System
查看>>
冒号和他的学生们(连载2)——首轮提问
查看>>
正则表达式与文件格式化处理
查看>>
Java EE互联网轻量级框架整合开发
查看>>
Java语言程序设计(基础篇)
查看>>
大型网站技术架构:核心原理与案例分析
查看>>
JAVA并发编程实战
查看>>
RabbitMQ实战++高效部署分布式消息队列
查看>>
微服务设计
查看>>
Spring Cloud微服务实战
查看>>
C++ static 语义
查看>>
C++ static 语义
查看>>