w.donahue
w.donahue

Reputation: 10886

Launch AlertDialog not from an Activity

I am trying to launch an alert dialog when not in a class that extends activity, but I am on the GUI thread. I have access to my applications context and attempt to launch the alert dialog with that but get an error:

02-12 00:48:07.412: ERROR/AndroidRuntime(1322): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Does anybody know what I am doing wrong on this one?

Upvotes: 1

Views: 2778

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

You cannot launch a dialog except via an activity, sorry.

You are welcome to create an activity that uses Theme.Dialog or something to look a bit like a dialog, if you wish.

Upvotes: 5

Related Questions