Android: AndroidRuntime android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Wednesday, 27 June 2012

Android: AndroidRuntime android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Have you seen this ugly error where is is totally not supposed to be there?

Error: AndroidRuntime android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

I was working on an app about local restaurants in Niagara and had an about window.

Solution:

error
...
private static Context context;
....

MainActivity.context = getApplicationContext(); // this was causing some nasty errors.

correct
MainActivity.context = this;


Related
http://www.mkyong.com/android/android-alert-dialog-example/
http://stackoverflow.com/questions/1561803/android-progressdialog-show-crashes-with-getapplicationcontext

 Digg  Del.icio.us  Reddit  SlashDot

1 comment:

Anonymous said...

Hey there just wanted to give you a quick heads up.
The words in your article seem to be running off the screen in Internet explorer.
I'm not sure if this is a format issue or something to do with browser compatibility but I thought I'd
post to let you know. The design look great
though! Hope you get the issue fixed soon.
Cheers
My blog ; Click Here