Can't Override onPostExecute() method in AsyncTask Class or get it to trigger

有些话、适合烂在心里 提交于 2019-11-28 20:05:30

OnPostExecute() takes an argument (the object you return from doInBackground()). Change it to protected void onPostExecute(Void v). If you don't provide the argument, the method signatures do not match and the override annotation starts to complain that there is no function to override with this signature.

Try:

In the class try right click Source -> Override/Implement methods.. and look for the onPostExecute() method. It will give you complete method with all types of arguments should it get.

if you want your onPostExecute() to be overitten, simply use what was returned in your doInBackground() as an object in your onPostExecute().

For example...

    @Override
    protected void doInBackground(Void...args0){
        // your code here...
        return value;
    }
    @Override
    protected void onPostExecute(void value){
        //code to run
    }

You should add super.onPostExecute() method. For example:

@Override
protected void onPostExecute(Void nothing)
{
   super.onPostExecute(nothing);
}

EDIT: Guys, I have no idea why you are downvoting the answer. The questioner is missing an argument of onPostExecute() method and doesn't have a supertype method implemented it. Thats's the reason I posted this answer.

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