Search This Blog

Friday, November 11, 2011

Android open dialog; Unable to start activity ComponentInfo Unable to add window token null is not for an application

When I tried to open a dialog with getApplicationContext() this error prevented me from accomplishing the goal:

“Unable to start activity ComponentInfo Unable to add window token null is not for an application”

Dialog loginDialog = new Dialog(this);
loginDialog.setContentView(R.layout.loginlayout);
loginDialog.setTitle(R.string.loginScreenHeader);
loginDialog.show();

DO NOT USE:

Context mContext = getApplicationContext();
Dialog loginDialog = new Dialog(mContext);

No comments:

Post a Comment

If you like this post, please leave a comment :)