开发者

Solving errors with a stacktrace

开发者 https://www.devze.com 2023-04-07 12:30 出处:网络
I got an error that its stacktrace doesn\'t reveal where in my classes (& line number) the error lies.

I got an error that its stacktrace doesn't reveal where in my classes (& line number) the error lies. Is there another way I can locate the code that causes this error?

I understand the error itself... but there are a couple of places in my code that could cause this and I can't reproduce it... (got the stacktrace from a user report).

Here's the stacktrace:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@462e1370 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:509)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:4开发者_Go百科24)
at android.app.Dialog.show(Dialog.java:241)
at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

Thank you!


You are probably trying to show a dialog when the user has paused or killed the app. Check all your alertDialogs and how you show these. Make sure your activity is running. For example you could use isFinishing


Comment is now an answer as requested:

I'm thinking that the exception is coming from a different thread. This seems to be the event thread of Android while you execute code in the worker thread that results in code being executed in the event thread. Like slayton suggested in his comment add some comments. However, also try to comment out parts of the code and see what line causes that exception.

0

精彩评论

暂无评论...
验证码 换一张
取 消