Android异常一、异步任务导致的窗口句柄泄漏问题(转)
05-05 10:36:41.009: E/WindowManager(4243): Activity com.tao.MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405241b0 that was originally added here
05-05 10:36:41.009: E/WindowManager(4243): android.view.WindowLeaked: Activity com.tao.MyActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405241b0 that was originally added here
05-05 10:36:41.009: E/WindowManager(4243): at android.view.ViewRoot.<init>(ViewRoot.java:265)
05-05 10:36:41.009: E/WindowManager(4243): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
05-05 10:36:41.009: E/WindowManager(4243): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
05-05 10:36:41.009: E/WindowManager(4243): at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.Dialog.show(Dialog.java:241)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ProgressDialog.show(ProgressDialog.java:107)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ProgressDialog.show(ProgressDialog.java:95)
05-05 10:36:41.009: E/WindowManager(4243): at com.unifable.activity.MySecretaryActivity.onCreate(MySecretaryActivity.java:50)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-05 10:36:41.009: E/WindowManager(4243): at android.os.Handler.dispatchMessage(Handler.java:99)
05-05 10:36:41.009: E/WindowManager(4243): at android.os.Looper.loop(Looper.java:130)
05-05 10:36:41.009: E/WindowManager(4243): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-05 10:36:41.009: E/WindowManager(4243): at java.lang.reflect.Method.invokeNative(Native Method)
05-05 10:36:41.009: E/WindowManager(4243): at java.lang.reflect.Method.invoke(Method.java:507)
05-05 10:36:41.009: E/WindowManager(4243): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:906)
05-05 10:36:41.009: E/WindowManager(4243): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:664)
05-05 10:36:41.009: E/WindowManager(4243): at dalvik.system.NativeStart.main(Native Method) 这是在做一个项目的时候遇到的问题:在第一界面的Activity中,为了避免程序假死带来的糟糕的用户体验,采用异步任务AsyncTask来访问网络,与服务器进行交互,并用
ProgressDialog控件来告知用户当前的程序进度。 在网上查了下别人的资料。才终于明白了原因。
上面的异常的意思是:存在窗口句柄的泄漏,即未能及时的销毁某个PhoneWindow. 为什么会出现这样的情况,因为,在异步任务里面已经发生了严重的错误,而导致Activity的强制关闭。Activity强制关闭了,可是ProgressDialog并没有dismiss()掉,所以出现了
窗口句柄的泄漏。 而且,更严重的是,这个异常会覆盖我们在AsyncTask里面发生的真正异常,这往往会误导我们,把过多的精力放在查找所谓的内存泄漏的上面,而不是查找AsyncTask
中出现的错误。 参照别人的解决方法:
本解决方法并不能真正的解决问题,但是在一定程度上可以将真正导致错误的异常信息显露出来。即重写Activity的onDestory()方法,在该方法中调用dismiss()来解除对ProgressDialog
的引用。
本文转自http://blog.csdn.net/lonelyroamer/article/details/7536962
Android异常一、异步任务导致的窗口句柄泄漏问题(转)的更多相关文章
- Android异常:异步任务导致的窗口句柄泄漏问题
05-05 10:36:41.009: E/WindowManager(4243): Activity com.tao.MyActivity has leaked window com.android ...
- Android中AsyncTask异步
今天我们学习了 AsyncTack, 这是一个异步任务. 那么这个异步任务可以干什么呢? 因为只有UI线程,即主线程可以对控件进行更新操作.好处是保证UI稳定性,避免多线程对UI同时操作. 同时要把耗 ...
- Android开发之异步具体解释(二)之AsyncTask
请尊重他人的劳动成果,转载请注明出处:Android开发之异步具体解释(二)之AsyncTask http://blog.csdn.net/fengyuzhengfan/article/details ...
- Android异常分析(转)
关于异常 异常? 异常就是一种程序中没有预料到的问题,既然是没有预料到的,就可能不在原有逻辑处理范围内,脱离了代码控制,软件可能会出现各种奇怪的现象.比如:android系统常见异常现象有应用无响应. ...
- Android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
Android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that cr ...
- Android异常:唤醒锁未授权。(Caused by: java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK.)
Android异常:Caused by: java.lang.SecurityException: Neither user 10044 nor current process has android ...
- Android中解决图像解码导致的OOM问题
Android中解决图像解码导致的OOM问题 原文链接:http://blog.csdn.net/zjl5211314/article/details/7042017
- Android开发之异步消息处理机制Handler
更加详细的介绍Handler的博文-http://blog.csdn.net/guolin_blog/article/details/9991569 Android中的异步消息处理主要有四个部分组成, ...
- Android线程之异步消息处理机制(二)——Message、Handler、MessageQueue和Looper
异步消息处理机制解析 Android中的异步消息处理主要有四个部分组成,Message.Handler.MessageQueue和Looper. 1.Message Message是在线程之间传递的消 ...
随机推荐
- Android应用框架浅析
http://blog.csdn.net/yanbober/article/category/3206943 Android应用层View绘制流程与源码分析 http://blog.csdn.ne ...
- rsyncd.conf 文件
uid = nobodygid = nobodymax connections = 10timeout = 60use chroot = noread only = falsepid file=/va ...
- HDU 5808[数位dp]
/* 题意: 给你l和r,范围9e18,求l到r闭区间有多少个数字满足,连续的奇数的个数都为偶数,连续的偶数的个数都为奇数. 例如33433符合要求,44不符合要求.不能含有前导零. 思路: 队友说是 ...
- (medium)LeetCode 224.Basic Calculator
Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...
- CCParticleSystem粒子系统
欢迎转载!转载时请注明出处:http://write.blog.csdn.net/postedit/8124781 第一次接触粒子系统,以前游戏里面的一些小特效,像制作动画一样,是采用一帧一帧的切出来 ...
- ubuntu实用技巧
添加alias ~/.bash_alias文件: alias go="python /Users/xhat/Downloads/goagent/local/proxy.py" ~/ ...
- Sqoop导数据出现的问题
sqoop导数据卡住在INFO mapreduce.Job: Running job: job_1447835049223_0010 查yarn日志全是: INFO org.apache.hadoop ...
- (整理)C#实现UDP广播
(一) IP地址解析 IP地址的类型:XXX.XXX.XXX.XXXA类: 1.0.0.1--126.255.255.254 最高位是0: 1个字节的网络地址和3个地址的主机地址 测试地址:127.X ...
- 11g RMAN Restore archivelog用法
I.备份所有归档日志文件 RMAN> BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVE ...
- PetaPoco修改
else if (type == typeof(decimal)) return (decimal)pk == default(decimal); public override void PreEx ...