I am trying to make a simple ProgressDialog while my AsyncTask is AsyncTask data. In my onPreExecute() method, I have this:
pd = ProgressDialog.show(c, "Loading...", "Please wait");
c is the context passed to the constructor of my AsyncTask from this.getApplicationContext() . Unfortunately, I keep getting an exception from this post:
Unable to add window - zero token is not for application
What am I doing wrong?
Update: Using this instead of this.getApplicationContext() revealed yet another problem. When I call ProgressDialog.show(... , the ProgressDialog indicator is displayed, but only after AsyncTask completed. In other words, the data is loaded and then a dialog is displayed. If I include pd.dismiss() in my onPostExecute() , then I even I will not see the dialogue (presumably because it is closed before it ever opens).
Final Solution: It turns out that fetch.get() distorts the UI thread and does not allow the display of ProgressDialog.
android android-asynctask progressdialog
Computerish
source share