惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - 清炒白菜

Unable to resume activity : android.database.StaleDataException: Attempted to access a cursor after it has been closed. 异常 计算2个经纬度之间的距离 用bcp导入DateTime类型的数据 Linux下提示“omitting directory”错误的解决办法 Android的"返回“功能 EditText获得焦点后,如何关闭软键盘 获取当前Activity的Root View 用代码动态设置ImageView的align布局 Android中Sqlite数据库多线程并发问题 [转]Java的数组(Array)、Vector、ArrayList、HashMap的异同 HTML中element.style取值问题 用bcp导入大量数据(代替INSERT) ajax跨域访问问题 又一款分布式版本控制工具Mercurial bcp导入导出数据发生异常解决方案 - 清炒白菜 - 博客园 导出Google Reader中加星的内容项 - 清炒白菜 - 博客园 在win下使用GIT dotNet 自带线程池与HTTP访问的若干疑问 解决"the database principal owns a schema in the database and cannot be dropped"问题
Android的匿名Handler类引起的内存泄露
清炒白菜 · 2013-05-16 · via 博客园 - 清炒白菜

2013-05-16 01:13  清炒白菜  阅读(391)  评论(0)    收藏  举报

具体原因参考这篇博客
http://blog.chengyunfeng.com/?p=468

上文中虽然给出了解决方案, 但是在实际操作的时候, 还是遇到一些问题。 
比如在Activity中的Field字段, 原先用匿名handler类 , 是可以直接访问的, 现在改了之后, 在MyHandler类中不能直接访问了。

暂时想到的办法是, 强制转换WeakReference<Activity> mActivity中保存的类型。

Activity act = mActivity.get()
if ( act == null) return;
MainActivity actNew = (MainActivity)act;

这样可以用actNew来访问MainActivity中的Field字段了。