我开始一个活动,我需要显示一个alertdialog,所以我写了一个对话框util类(dialoghandler),我将上下文传递给dialoghandler,第一次启动是好的,但是当我启动第二个时,它发生了例外。我该怎么办,ps帮助我。
这是错误报告:
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)
答案 0 :(得分:14)
您无法通过非活动的上下文显示应用程序窗口/对话框。请检查每次启动对话时它都会得到正确的上下文。