Andranik
Andranik

Reputation: 2849

Should I call super.onPostExecute(result) in Android AsyncTask?

I wonder if it has any meaning to call super.onPostExecute(result) or super.onPreExecute in Android AsyncTask? I have been always calling them, but even in Android documentation about AsyncTask (Android API Reference: AsyncTask) they are omitted. So does it make any sense if I call them or not?

Upvotes: 37

Views: 7833

Answers (2)

Josef Raška
Josef Raška

Reputation: 1301

It has no effect if you call them or not, becase both have empty implementation in AsyncTask and they are there only to allow you override them, but does not force you to do that.

Upvotes: 3

diegocarloslima
diegocarloslima

Reputation: 1346

No, there is no need to call the superclass. If you take a look at the AsyncTask source, you will see that the super class does nothing:

@SuppressWarnings({"UnusedDeclaration"})
protected void onPostExecute(Result result) {
}

Upvotes: 55

Related Questions