<bdo id='GEmdc'></bdo><ul id='GEmdc'></ul>

    <tfoot id='GEmdc'></tfoot>

    <i id='GEmdc'><tr id='GEmdc'><dt id='GEmdc'><q id='GEmdc'><span id='GEmdc'><b id='GEmdc'><form id='GEmdc'><ins id='GEmdc'></ins><ul id='GEmdc'></ul><sub id='GEmdc'></sub></form><legend id='GEmdc'></legend><bdo id='GEmdc'><pre id='GEmdc'><center id='GEmdc'></center></pre></bdo></b><th id='GEmdc'></th></span></q></dt></tr></i><div id='GEmdc'><tfoot id='GEmdc'></tfoot><dl id='GEmdc'><fieldset id='GEmdc'></fieldset></dl></div>
    1. <legend id='GEmdc'><style id='GEmdc'><dir id='GEmdc'><q id='GEmdc'></q></dir></style></legend>

      <small id='GEmdc'></small><noframes id='GEmdc'>

      致命异常:android.view.WindowManager$BadTokenException 无法添加窗口——令牌

      时间:2023-06-28

    2. <tfoot id='whU2O'></tfoot>
        <bdo id='whU2O'></bdo><ul id='whU2O'></ul>
        <i id='whU2O'><tr id='whU2O'><dt id='whU2O'><q id='whU2O'><span id='whU2O'><b id='whU2O'><form id='whU2O'><ins id='whU2O'></ins><ul id='whU2O'></ul><sub id='whU2O'></sub></form><legend id='whU2O'></legend><bdo id='whU2O'><pre id='whU2O'><center id='whU2O'></center></pre></bdo></b><th id='whU2O'></th></span></q></dt></tr></i><div id='whU2O'><tfoot id='whU2O'></tfoot><dl id='whU2O'><fieldset id='whU2O'></fieldset></dl></div>
          <tbody id='whU2O'></tbody>
          1. <small id='whU2O'></small><noframes id='whU2O'>

              <legend id='whU2O'><style id='whU2O'><dir id='whU2O'><q id='whU2O'></q></dir></style></legend>

              1. 本文介绍了致命异常:android.view.WindowManager$BadTokenException 无法添加窗口——令牌无效;您的活动正在运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道这个问题已经讨论过好几次了,但相信我,我从来没有得到任何有效的答案.在我的主要活动中,我使用了一些对话框来通知用户一些操作,但我在小米设备上大多(特别是 96%)得到这个特定的错误.`

                I know this question is discussed several time but believe me i never got any answer working. In my Main Activity i have used few Dialog to inform user about some operations but i get this specific error mostly (specifically 96%) on Xiaomi devices. `

                Fatal Exception: android.view.WindowManager$BadTokenException
                Unable to add window -- token android.os.BinderProxy@f839de9 is not valid; is your activity running?
                android.view.ViewRootImpl.setView (ViewRootImpl.java:697)
                android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:347)
                android.view.WindowManagerImpl.addView (WindowManagerImpl.java:94)
                android.widget.Toast$TN.handleShow (Toast.java:463)
                android.widget.Toast$TN$2.handleMessage (Toast.java:346)
                android.os.Handler.dispatchMessage (Handler.java:102)
                android.os.Looper.loop (Looper.java:163)
                android.app.ActivityThread.main (ActivityThread.java:6377)
                java.lang.reflect.Method.invoke (Method.java)
                com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:904)
                

                com.android.internal.os.ZygoteInit.main (ZygoteInit.java:794)<代码>我介绍了每个 Dialog Show 方法,例如

                com.android.internal.os.ZygoteInit.main (ZygoteInit.java:794) I covered each Dialog Show method like

                if (!MainActivityNew.this.isFinishing())
                dialogDownload.show();
                

                `但我仍然在发布模式下遇到此错误,主要是在 Xiaomi 设备上使用 Android 版本 7,请帮我解决过去一个月的这个问题.

                ` But still i am getting this error in release mode mostly on Xiaomi Devices With Android Version 7, Please help me i stuck on this problem from past one month.

                这是来自 firebase Crashlytics 的一些数据

                Here is some data from firebase Crashlytics

                设备100% 小米操作系统100% 安卓 7设备状态4% 背景

                Devices 100% Xiaomi Operating systems 100% Android 7 Device states 4% background

                推荐答案

                这个问题不是因为Dialog,而是Toast.主要是这个 Toast 问题在上下文变为空的 android 7.1 版本中.这位先生创建了一个解决方案 Solution .我已经测试过了,效果很好.你可以试试这个.

                This problem is not because of Dialog but with Toast. Mainly this Toast issue is in android 7.1 version where the context become null. There is a solution created by this gentleman Solution . I have tested and this is working very well. You can try this.

                 if (android.os.Build.VERSION.SDK_INT == 25) {
                                ToastCompat.makeText(context, message, Toast.LENGTH_SHORT)
                                        .setBadTokenListener(toast -> {
                                            Log.e("failed toast", message);
                                        }).show();
                            } else {
                                Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
                            }
                

                这篇关于致命异常:android.view.WindowManager$BadTokenException 无法添加窗口——令牌无效;您的活动正在运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:无法解析方法'show(android.support.v4.app.FragmentManager, java 下一篇:创建 Java 对话框

                相关文章

                <small id='RMH5k'></small><noframes id='RMH5k'>

                      <bdo id='RMH5k'></bdo><ul id='RMH5k'></ul>
                  1. <legend id='RMH5k'><style id='RMH5k'><dir id='RMH5k'><q id='RMH5k'></q></dir></style></legend>
                    <i id='RMH5k'><tr id='RMH5k'><dt id='RMH5k'><q id='RMH5k'><span id='RMH5k'><b id='RMH5k'><form id='RMH5k'><ins id='RMH5k'></ins><ul id='RMH5k'></ul><sub id='RMH5k'></sub></form><legend id='RMH5k'></legend><bdo id='RMH5k'><pre id='RMH5k'><center id='RMH5k'></center></pre></bdo></b><th id='RMH5k'></th></span></q></dt></tr></i><div id='RMH5k'><tfoot id='RMH5k'></tfoot><dl id='RMH5k'><fieldset id='RMH5k'></fieldset></dl></div>

                  2. <tfoot id='RMH5k'></tfoot>