该异常表示view没有添加到窗口管理器,通常是我们dismiss对话框的时候,activity已经不存在了,建议不要在非UI线程操作对话框。
[解决方案]:常发生这类Exception的情形都是,有一个费时的线程操作,需要显示一个Dialog,在任务开始的时候显示一个对话框,然后当任务完成了在Dismiss对话框,如果在此期间如果Activity因为某种原因被杀掉且又重新启动了,那么当dialog调用dismiss的时候WindowManager检查发现Dialog所属的Activity已经不存在,所以会报错。
要避免此类Exception,就要正确的使用对话框,也要正确的使用线程:
1.不要在非UI线程中使用对话框创建,显示和取消对话框;
2.尽量少用单独线程,出发是真正的耗时操作采用线程,线程也不要直接用Java式的匿名线程,除非是那种单纯的操作,操作完成不需要做其他事情的。
3.如果是在fragment中发起异步网络的回调中进行dialog的操作,那么在操作之前,需要判断 isAdd( ),避免fragment被回收了但是还要求dialog去dismiss
4.在Activity onDestroy中对Dialog提前进行关闭

dialog--not attached to window manager的更多相关文章

  1. 关于dialog引起的 java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView not attached to window manager 错误的分析

    在跑Monkey测试的时候出现了一个比较特别的问题,先来看看Log: // CRASH: com.meizu.media.painter (pid 12491) // Short Msg: java. ...

  2. bug_ _java.lang.IllegalArgumentException: View not attached to window manager 2

    今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...

  3. bug_ _java.lang.IllegalArgumentException: View not attached to window manager

    ============= 1   view not attached to window manager 转自:http://hi.baidu.com/spare_h/blog/item/7fa3e ...

  4. Android中 View not attached to window manager错误的解决办法

    前几日出现这样一个Bug是一个RuntimeException,详细信息是这样子的:java.lang.IllegalArgumentException: View not attached to w ...

  5. 关于java.lang.IllegalArgumentException: View not attached to window manager 错误的分析

    今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...

  6. decorview that was originally added here or java.lang.IllegalArgumentException: View not attached to window manager

    使用Dialog的时候,没少出现下面这两个报错 12-11 17:47:49.776: E/WindowManager(11461): android.view.WindowLeaked: Activ ...

  7. View not attached to window manager

    java.lang.IllegalArgumentException: View not attached to window manager 在用ProgressDialog的时候,任务结束后Dis ...

  8. View not attached to window manager crash 的解决办法

    View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...

  9. java.lang.IllegalArgumentException: View not attached to window manager

    公司项目线上bug: java.lang.IllegalArgumentException: View not attached to window manager at android.view.W ...

随机推荐

  1. SpringMvc和Mybatis整合总结

    1.先配置mybatis,测试读取数据库 2.自己测试数据 3.配置spring和springmvc, PS:配置web.xml,这样就不用getBean了 4.配置Controller 5.前后台交 ...

  2. Linux 修改yum源

    第一种方式: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 第二种方式: ...

  3. about unit test

    Use unify unit test framework CPPUnit 1.12.1/Visual stdio Unit is a class or a function Test per maj ...

  4. Android之根布局动态载入子布局时边距设置无效问题

    Android大部分的控件都会有padding和layout_margin两个属性,一般来说它们的差别是: padding:控件中的内容离控件边缘的距离. margin:  控件离它的父控件边缘的距离 ...

  5. Unity API 解析 (陈泉宏著)

    1 Application类 2 Camera类 3 GameObject类 4 HideFlags类 5 Mathf类 6 Matrix4x4类 7 Object类 8 Quaternion类 9 ...

  6. REPL

    REPL(Read Eval Print Loop:交互式解释器) 表示一个电脑的环境,类似 Window 系统的终端或 Unix/Linux shell,我们可以在终端中输入命令,并接收系统的响应. ...

  7. python之路---06 小数据池 编码

    二十二.小数据池, id()    进行缓存 1.小数据池针对的是: int, str, bool 2.在py文件中几乎所有的字符串都会缓存.   在cmd命令窗口中几乎都不会缓存   不同的解释器有 ...

  8. Dynamic Signals and Slots

    Ref https://doc.qt.io/archives/qq/qq16-dynamicqobject.html Trolltech | Documentation | Qt Quarterly ...

  9. 3d tech

    product Company    3D "smart cameras" such as the Gocator LMI Technologies (Delta, BC Cana ...

  10. openstack常见问题

    openstack通过kolla-ansible添加一个计算节点,并部署后,发现控制节点上无法发现新加的计算节点, 在控制节点的  nova_scheduler.nova_api容器上执行发现计算节点 ...