小编Mar*_*Bar的帖子

覆盖AsyncTask中的前/后执行并调用super.onPre/PostExecute

在AsyncTask中覆盖onPreExecute时,是否必须调用super.onPreExecute?AsyncTask.onPreExecute和其他方法实际上做了什么?onPostExecute和onCancelled的问题相同

public class MyAsyncTask extends AsyncTask<Void, Void, Boolean> 
{

@Override
protected void onCancelled(Boolean result) {

    super.onCancelled(result);   //<-DO I HAVE TO?

            //My onCancelled code below


}

@Override
protected void onPostExecute(Boolean result) {

    super.onPostExecute(result);  //<-DO I HAVE TO?

            //My onPostExecute code below
}

@Override
protected void onPreExecute() {

    super.onPreExecute();  //<-DO I HAVE TO?

            //My onPreExecute code below

}

@Override
protected Boolean doInBackground(Void... params) {

    return null;
}
Run Code Online (Sandbox Code Playgroud)

java android android-asynctask

4
推荐指数
1
解决办法
3683
查看次数

标签 统计

android ×1

android-asynctask ×1

java ×1