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

为君一笑 提交于 2021-02-06 14:21:20

问题


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?


回答1:


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) {
}



回答2:


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.



来源:https://stackoverflow.com/questions/20637355/should-i-call-super-onpostexecuteresult-in-android-asynctask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!