gpt4 book ai didi

android - BadTokenException异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:59:05 24 4
gpt4 key购买 nike

我开始一个 Activity ,我需要显示一个警报对话框,所以我写了一个对话框实用程序类(dialoghandler),我将上下文传递给对话框处理程序,第一次启动没问题,但是当我启动第二个时,它发生了exception.what should I do,ps help me.

这是错误报告:

12-03 07:23:26.000: ERROR/AndroidRuntime(21525): FATAL EXCEPTION: main
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.ViewRoot.setView(ViewRoot.java:509)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.app.Dialog.show(Dialog.java:241)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.update.EoeSdkUpdate.onCacheFetched(EoeSdkUpdate.java:170)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager.handleCallBackMag(CacheManager.java:362)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager.access$1(CacheManager.java:358)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager$CallbackHandler.handleMessage(CacheManager.java:375)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.os.Looper.loop(Looper.java:123)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at java.lang.reflect.Method.invoke(Method.java:521)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at dalvik.system.NativeStart.main(Native Method)

最佳答案

您不能通过不是 Activity 的上下文显示应用程序窗口/对话框。请检查每次启动对话时它都会获得正确的上下文。

关于android - BadTokenException异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4343393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com