I know there are multiple instances of this question, but I have never seen a stack trace like we are getting now, so I'm asking a separate question.
We are getting reports from Fabric that, at handleResumeActivity
of the ActivityThread.java there is something happening. For some reason, onResume
cannot be performed, and we are not getting a clear stack trace, so I'm looking for answers that what could cause this issue.
Here is the stack trace:
Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@474da0e is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:579)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3187)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
The exception does not correlate any of the code we've written, and apparently this happens really frequently while not depending on API versions. (Changed this part after deep examining of logs.)
Side note: We are using ViewPager
with 2 fragments, AlertDialog
views and some DialogFragment
instances in our application, but none of them are re-instantiated at onResume
calls. Also the stack trace proves that onResume
of any activity has not called at all.
I need to find the source of this exception since apparently we can't handle it by adding a try-catch or something. What could be done to prevent this exception? Any help is appreciated, thanks.