Reputation: 931
I have the following generally happening for an AsyncTask:
private class backgroundTask extends AsyncTask<Object, Object, Object> {
protected void onPreExecute() {
this.dialog.setMessage("Doing stuff...");
this.dialog.show();
}
@Override
protected Object[] doInBackground(Object... params) {
// stuff happens here
ResultsObject results = new ResultsObject(processValue);
Object[] values = new Object[2];
values[0] = "STATUS STRING";
values[1] = results;
return values;
}
protected void onPostExecute(Object... result) {
Log.d("actions", "onPostExecute");
if (this.dialog.isShowing())
this.dialog.dismiss();
}
}
However, onPostExecute does not appear to be getting triggered. I can validate that everything up until doInBackground makes a return call is getting executed. This has to be something obscenely simple that I'm missing here, but I'm stumped. I have other AsyncTasks in this same project, and I have no trouble with them reaching onPostExecute.
Upvotes: 0
Views: 201
Reputation: 44118
You're overloading onPostExecute
method and it doesn't get used. Use this:
@Override
protected void onPostExecute(Object o) {
super.onPostExecute(o);
Log.d("actions", "onPostExecute");
if (this.dialog.isShowing())
this.dialog.dismiss();
}
Note the @Override
annotation, it comes very useful in times like this. It will show an error if the method you are trying to override doesn't exist.
Upvotes: 1