报错:

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. Python编程之美:最佳实践指南PDF高清完整版免费下载|百度云盘|Python新手到进阶

    百度云盘:Python编程之美:最佳实践指南PDF高清完整版免费下载 提取码:1py6 内容简介 <Python编程之美:最佳实践指南>是Python用户的一本百科式学习指南,由Pytho ...

  2. 痞子衡嵌入式:16MB以上NOR Flash使用不当可能会造成软复位后i.MXRT无法正常启动

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家分享的是i.MXRT上使用16MB以上NOR Flash软复位无法正常启动问题的分析解决经验. 痞子衡这几天在支持一个i.MXRT1050客户项 ...

  3. css中的名词

    用到的单词 current 当前 hover 悬停 selected 挑选 disabled 禁用 focus 得到焦点 blur 失去焦点 checked 勾选 success 成功 error 出 ...

  4. 【laravel】基于jwt实现用户认证

    安装及基础配置 使用 composer 安装 # 建议使用1.0以上版本 composer require tymon/jwt-auth .*@rc 进行一些配置 有些文档会说要添加 Tymon\JW ...

  5. 使用ATOMac进行Mac自动化测试

    ATOMac简介 atomac是一个支持在mac上做自动化的python库,GitHub地址如下: https://github.com/pyatom/pyatom 安装 # Python2 sudo ...

  6. Python之自定义函数

    函数 1.定义函数 在Python中定义一个函数要使用def语句,一次写出函数名.括号.括号中的的参数和冒号,然后在缩进块中编写函数体,函数的返回值用return返回.如下所示: def 函数名(参数 ...

  7. jieba尝鲜

    import jieba strings = '我工作在安徽的安徽师范大学,这个大学很美丽,在芜湖' # print(dir(jieba)) dic_strings = {} lst_strings ...

  8. Python os.minor() 方法

    概述 os.minor() 方法用于从原始的设备号中提取设备minor号码 (使用stat中的st_dev或者st_rdev field ).高佣联盟 www.cgewang.com 语法 minor ...

  9. BSGS 学习笔记

    问题:求$a^x\equiv b\ (mod\ p)$的最小正整数解. 这时候就要用到BSGS(拔山盖世)算法.直接进入正题: 设$x=im-n$, 则原式等于$a^{im-n}\equiv b\ ( ...

  10. python7.4邮件发送