Create Options from a class that extends View Parent Class

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Create Options from a class that extends View Parent Class

Postby viju85 » Wed Feb 03, 2010 5:27 am

I am developing an application and i am unable to sovle this issue for about a week.
May be this sounds trivial, but i guess it may be very useful to many others like me.

I have a class A that extends Activity which calls another class B that extends View using setContentView().

Within the class B i am not able to make use of AlertDialog or any Dialog for that matter.
I get the following error on logcat:

Exception in alertNewGame() Method: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Please help me on how to go about it.

Junior Developer
Junior Developer
Posts: 20
Joined: Mon Feb 23, 2009 10:17 pm


Postby jwei512 » Wed Feb 03, 2010 10:58 am

I think typically that means you are trying to open a window from outside of the main UI thread...

In other words, AlertDialogs/Dialogs can only be instantiated from within the Activity
- jwei
Examples, Code, and Tutorials
Senior Developer
Senior Developer
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests