hbb20 / hbb20/CountryCodePickerProject

Unable to add window -- token null is not valid; is your activity running?

未关闭
#609 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
1.5k
派生
509
PR 合并指标
30 天内没有已合并 PR

描述

`Process: com.example.android, PID: 10996
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:907)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:387)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
at android.app.Dialog.show(Dialog.java:342)
at com.hbb20.CountryCodeDialog.openCountryCodeDialog(CountryCodeDialog.java:265)
at com.hbb20.CountryCodePicker.launchCountrySelectionDialog(CountryCodePicker.java:2207)
at com.hbb20.CountryCodePicker.launchCountrySelectionDialog(CountryCodePicker.java:2199)
at com.hbb20.CountryCodePicker$1.onClick(CountryCodePicker.java:147)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)`

We are use ViewPager with custom view without fragment

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 stack trace 中显示的 CountryCodeDialog.openCountryCodeDialog 和 CountryCodePicker.launchCountrySelectionDialog 调用路径开始。使用在 ViewPager 内部的库和不带 fragment 的自定义 view 重现该故障,然后检查 dialog 如何获取其 activity context。在该设置下能够打开国家选择且不出现 BadTokenException,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, java
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。