Issue
I tried to run my app in an genymotion emulator however this is the error that I always get.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.danicaabinuman.workforce, PID: 2087
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@7ee39fa 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: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 tried to run my app to an android mobile and the error did not occur. My app works perfectly fine. Please help me.
Solution
It looks like you're trying to show a Toast after your activity has already been closed. Do you have a background thread or task that shows the Toast when it finishes? If so, you should check whether the activity has been destroyed prior to showing the toast, by calling isFinishing().
Answered By - Dmitry Brant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.