saketr64x
saketr64x

Reputation: 56

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@aba286f is not valid; is your activity running?

All of sudden my app crashes in between smooth sailing.

Complete error:

 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:434)
 at android.widget.Toast$TN$2.handleMessage(Toast.java:345)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6119)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I am finding it very hard to debug . Please throw some light on how to debug it .Thanks for the help.

IMPORTANT NOTE This is not a duplicate of Error : BinderProxy@45d459c0 is not valid; is your activity running?.

I am not using any dialog in my app . Yes i am indeed using simple Toasts . But its not clear whats causing the error....

UPDATE:This error is happening the activity that has TabbedLayout.I have removed all toasts,the error still persists.I have used Logs instead

Upvotes: 1

Views: 1139

Answers (2)

Sandeep Singh
Sandeep Singh

Reputation: 11

This exception comes when trying to perform operation on main thread while thread does not exist. This happens when you are showing dialog in a activity/fragments but that class is already finished, so this exception come.

To handle this exception while showing any types of dialog check the isFinishing() status.

Upvotes: 1

Sameer Jani
Sameer Jani

Reputation: 1030

There might be context would be old window (Activity) where Activity configuration might be change and you may preserve old context which has no any window available right now.

That's why this could be occurred.

Please check your code is there any configuration change or Activity get refresh?

And your Toast class inside you are giving closed window or old window context which is not actually present.

Upvotes: 0

Related Questions