4

I've gone through lot of posts about this issue before I post my own question , and Im still not able to find any solution to it , in fact I don't even know where the problem is !

I keep getting this crash everyday on my crashlytics dashboard ( only for few users ) . Unfortunately its only giving me the crash infos but not showing which line or class is causing it , and other thing is that 100% of devices affected are using Android 7 & most of them are Amlogic devices ( eg : X96 mini , TX3 mini )

I understand that this is most likely happening because Im trying to show a dialog after execution of a background thread, while the Activity is being destroyed , so I checked all my code and I've added to each dialog the condition below

if(!YourActivityName.this.isFinishing()) 
{
    //show dialog
}

Here is the LogCat:

Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@499c862 is not valid; is your activity running?
   at android.view.ViewRootImpl.setView(ViewRootImpl.java:679)
   at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
   at android.widget.Toast$TN.handleShow(Toast.java:459)
   at android.widget.Toast$TN$2.handleMessage(Toast.java:342)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6121)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Chawkii
  • 221
  • 5
  • 13
  • 1
    There is this `at android.widget.Toast$TN.handleShow(Toast.java:459)` error message from your logcat, so this might be related to `Toast` instead of `Dialog`. I think it's the same issue as this https://stackoverflow.com/questions/51532449/fatal-exception-android-view-windowmanagerbadtokenexception-unable-to-add-wind – Leminerale Jul 27 '20 at 13:09

0 Answers0