0

When using set error message inside popup window,application is crashing.

Error:- android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@c912902 is not valid; is your activity running?

Thanks in advance.

computingfreak
  • 4,939
  • 1
  • 34
  • 51
Patel Hiren
  • 61
  • 11
  • this error usually occur if Your activity will be destroyed. It´s possible that another issue stops the activity and in case of overlap, it crashs twice beacuse of a dialog that is shown without an existing activity. But there are also other possible issues. Maybe it helps if You put Your popup show method inside an if/else statement like: if(!((Activity) context).isFinishing()) – Opiatefuchs Feb 22 '16 at 12:52

1 Answers1

0

Adding a code along with your question would have been a better idea. However, You might be showing your popup too early. You may post a delayed runnable for showatlocation in Onresume , Give it a try.

Else go through this post which seems to have the same problem answered Unable to add window

Further you can also refer this link to solve your problem

Community
  • 1
  • 1
Naresh Narsing
  • 765
  • 6
  • 9