报错:

Attempted to add application window with unknown token XXX
Unable to add window——token android.os.BinderProxy@196e65b8 is not valid;is your activity is running?

原因:

网上很多前辈都说是要传入当前的Activity, 而不是传getAppicationContext,但是检查自己的代码发现,传入的确实是当前的Activity,心都要凉一半,因为周五了,一切顺利的快要下班前一刻,出现这种小问题造成大bug,太sad了。
网上搜索有一篇也是和我情况类似的,但是说了好多,最后没有贴出解决方法,对于小白的我,emmmm,一言难尽。
而后想到,是不是没有在Activity的生命周期最后干掉dialog,于是马上行动,解决了自己的bug,开心愉快高兴~

解决方法:

在Activity的onDestroy方法里关闭弹窗。

    @Override
protected void onDestroy() {
super.onDestroy();
// 关闭弹窗
DialogUtils.isShow(); }
    public static void isShow(){
try {
if (BUILDER != null)
{
BUILDER=null;
}
if (CUS_DIALOG!=null) {
CUS_DIALOG.cancel();
CUS_DIALOG.dismiss();
CUS_DIALOG = null;
dialogs.dismiss();
}
} catch (Exception e) {
e.printStackTrace();
}
}

若有问题,欢迎各位大佬指教~

add application window with unknown token XXX Unable to add window;is your activity is running?的更多相关文章

  1. bug_ _ android.view.WindowManager$BadTokenException: Unable to add window -- token

    ========4       关于android的一个常见错误:Unable to add window --token is not valid android.view.WindowManage ...

  2. android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

      原博客地址:http://aijiawang-126-com.javaeye.com/blog/662336 在Activity中newSpinner是我把mContext传入,但是出了 andr ...

  3. Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

    在广播中启动一个Dialog时出现如下错误信息:Caused by: android.view.WindowManager$BadTokenException: Unable to add windo ...

  4. Unable to add window -- token null is not for an application错误的解决方法 android开发

    Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not f ...

  5. android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an applic

    之前遇到过这样的问题, 04-12 10:40:33.302: E/AndroidRuntime(17213): Caused by: android.view.WindowManager$BadTo ...

  6. popupwindow使用之异常:unable to add window -- token null is not valid

    使用popwindow中又碰到一个白痴问题,在此留作纪念,希望对大家有帮助 popupwindow之所以叫这个名字,肯定是要从某个地方弹出啦,但是从哪个地方呢?必须是指定一个view嘛 void an ...

  7. Xamarin Android.Views.WindowManagerBadTokenException: Unable to add window -- token android.os.BinderProxy

    Android.Views.WindowManagerBadTokenException: Unable to add window -- token android.os.BinderProxy@ ...

  8. Activity has leaked window that was originally added -界面退出时未关闭对话框异常 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? -

    退出Activity时弹出登录框,点击确定finish当前Activity,结果报了这个错,随后查找资料知道 原因: 是因为退出Activity时没有关闭弹出框,出现了这个错误 解决方法: 只需要在a ...

  9. Unable to add window -- token android.os.BinderProxy@3a067204 is not valid错误分析记录

    打开APP时,出现闪退的情况,查看android studio报错信息,主要为: Unable to add window -- token android.os.BinderProxy@3a0672 ...

随机推荐

  1. 如何获取json某一级节点的数据

    如何获取json某一级节点的数据 最近做项目有获取和设置固定格式某一级节点值的需求.但是要一级一级地取对于多级的结构来说代码过于冗余且重复,于是写了个递归的方法根据json路径完成值的定点操作.废话不 ...

  2. Go语言基础语法总结

    1. 认识HelloWorld 在前面的<Go的安装和使用>这篇文章中已经写过HelloWorld.go了,现在就来逐行认识一下它. package main import "f ...

  3. PHP入门之流程控制

    前言 上一篇文章对PHP的一些类型和运算符进行了简单的讲解.PHP入门之类型与运算符 这篇简单讲解一下流程控制.结尾有实例,实例内容是用switch分支和for循环分别做一个计算器和金字塔. 分支控制 ...

  4. Debug LinkedList

    Debug LinkedList源码 前置知识 LinkedList基于链表,LinkedList的Node节点定义 成员变量 //链表中元素的数量 transient int size = 0; / ...

  5. Java 线程池记录

    Java通过Executors提供四种线程池,分别为:newCachedThreadPool创建一个可缓存线程池,如果线程池长度超过处理需要,可灵活回收空闲线程,若无可回收,则新建线程.newFixe ...

  6. redis 之 持久化

    Redis支持RDB和AOF两种持久化机制,持久化功能有效地避免因进程退出造成的数据丢失问题,当下次重启时利用之前持久化的文件即可实现数据恢复. 1.RDB持久化 RDB持久化是指在指定的时间间隔内将 ...

  7. 深度学习论文翻译解析(十一):OverFeat: Integrated Recognition, Localization and Detection using Convolutional Networks

    论文标题:OverFeat: Integrated Recognition, Localization and Detection using Convolutional Networks 标题翻译: ...

  8. 【算法】题目分析:Aggressive Cow (POJ 2456)

    题目信息 作者:不详 链接:http://poj.org/problem?id=2456 来源:PKU JudgeOnline Aggressive cows[1] Time Limit: 1000M ...

  9. PHP image_type_to_extension - 获取图片后缀

    image_type_to_extension — 根据指定的图像类型返回对应的后缀名.高佣联盟 www.cgewang.com 语法 string image_type_to_extension ( ...

  10. PHP xml_set_character_data_handler() 函数

    定义和用法 xml_set_character_data_handler() 函数为 XML 解析器建立字符数据处理器. 该函数规定当解析器在 XML 文件中找到字符数据时所调用的函数.高佣联盟 ww ...