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?
Asked
Active
Viewed 7,784 times
37
-
no you can omit the call to the super – Blackbelt Dec 17 '13 at 14:55
-
need not but it is better you do – Raghunandan Dec 17 '13 at 14:57
2 Answers
55
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) {
}

diegocarloslima
- 1,346
- 14
- 16
-
but, then how can I return the result, so I can get (`.execute().get();`) it in other activity ? – Francisco Corrales Morales May 09 '14 at 16:02
3
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.

Josef Raška
- 1,291
- 10
- 8