The first time a user ever runs my app, I show the options menu by
doing something like this in Activity.onCreate():
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
openOptionsMenu();
}
}, 500);
However, using analytics, I can see that very occasionally (< 1% of
the time) openOptionsMenu() throws this exception:
android.view.WindowManager$BadTokenException: Unable to add window --
token null is not valid; is your activity running?
I've tried catching this exception, but then other exceptions follow.
Is there any way to avoid this? Maybe a test to see whether the
activity is still running? If so, what is the most reliable way to do
that?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en