Reputation: 51
When a button is clicked I'm calling the async class in a function and I need to show progressDialog until it runs the displaylist function. But it shows up only after the function finished running and closes immediately. Please help me what am I doing wrong here.
public class FilterAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog dispProgress;
@Override
protected void onPreExecute()
{
dispProgress = ProgressDialog.show(Filter.this, "Please wait...",
"Loading...", true, true);
}
protected Void doInBackground(Void... params) {
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
MerchantsActivity.displayList();
dispProgress.cancel();
finish();
}
}
Upvotes: 0
Views: 489
Reputation: 38707
Your AsyncTask will complete immediately because you do exactly nothing in doInBackground()! That's where your long-running background non-UI code is supposed to go...
Upvotes: 1
Reputation: 46943
I would recommend you not to use the static ProgressDialog#show
method. Rather donew ProgressDialog()
and initialize it accordingly and finally call show()
. I have never used the static method and do not know how it works, but I have used the other option. Furthermore the static method seems to have no available documentation.
Upvotes: 0