I'm having a problem with a listener in a certain activity.
The problem is that this listener contains an alert.show(); which can be called after we try to push a new activity (which then gives an exception).
e.g.: I'm listening in activity A for a signal from an other phone. I press back and try to run a new activity B but the program crashes because of the alert.show() A's listener.
ERROR/AndroidRuntime(3573): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@476c21c0 is not valid; is your activity running?
Can I check in A's listener whether this activity is active and then show the alert or not depending on this value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…