So I am having some difficulties with Android Dialogs. All I want to do is display a dialog when a button is pressed, and then when my AsyncTask is done, dismiss it. I can’t even get it to display though. Here is my code for the dialog inside my OnClick listener:
ProgressDialog dialog = ProgressDialog.show(getApplicationContext(), "",
"Loading. Please wait...", true);
My Logcat says that it is unable to add window. Here it is:
01-21 17:44:48.044: E/AndroidRuntime(6319): at android.app.ProgressDialog.show(ProgressDialog.java:116)
How do I get the dialog to show up?
EDIT:
The problem was that when I was getting the Context, it wasn’t getting my Activity’s context. So I made a variable that was set to my Activity’s context and passed that in fixing it.
You shouldn’t use getApplicationContext() for this, several people have had problems using it. Can you use the context of your activity one way or another?