Java 受保护的void onPostExecute错误

Java 受保护的void onPostExecute错误,java,android,android-asynctask,Java,Android,Android Asynctask,当我尝试实现onPostExecute方法时,它会给我一个错误,即删除@Override,并且需要调用一个超类或方法。然而,我确实调用了超类等等。这是我的异步任务的代码 public class parsenfill extends AsyncTask<Void,Void,Void> { @Override protected Void doInBackground(Void... params) { try { JsonP

当我尝试实现onPostExecute方法时,它会给我一个错误,即删除@Override,并且需要调用一个超类或方法。然而,我确实调用了超类等等。这是我的异步任务的代码

    public class parsenfill extends AsyncTask<Void,Void,Void> {

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

        try {
        JsonParsing parse = new JsonParsing(url);
        parse.parseFile(3, urls);
        return null;
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void...voids ) {
        super.onPostExecute(voids);
                    //Body of method

    }
}
公共类parsenfill扩展异步任务{
@凌驾
受保护的Void doInBackground(Void…参数){
试一试{
JsonParsing=新的JsonParsing(url);
parse.parseFile(3,URL);
返回null;
}
捕获(例外e){
e、 printStackTrace();
}
返回null;
}
@凌驾
PostExecute上受保护的void(void…voids){
super.onPostExecute(无效);
//方法体
}
}

从方法签名中删除
onPostExecute
的参数类型是
doInBackground()
的返回类型,即在您的情况下仅为纯
Void

错误: 因为。。。表示字符串数组,背景返回void

对的: 试试这个

private class MyAsyncClass extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPreExecute() {

        /**
         * invoked on the UI thread before the task is executed. This step
         * is normally used to setup the task, for instance by showing a
         * progress bar in the user interface.
         */

        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... params) {
        /**
         * Invoked on the background thread immediately after onPreExecute()
         * finishes executing. This step is used to perform background
         * computation that can take a long time. The parameters of the
         * asynchronous task are passed to this step.
         */
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        /**
         * Invoked on the UI thread after the background computation
         * finishes. The result of the background computation is passed to
         * this step as a parameter.
         */
        super.onPostExecute(result);
    }

}

可能是重复的谢谢。回答了我的问题
@Override
protected void onPostExecute(Void voids ) {
    super.onPostExecute(voids);
                //Body of method

}
private class MyAsyncClass extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPreExecute() {

        /**
         * invoked on the UI thread before the task is executed. This step
         * is normally used to setup the task, for instance by showing a
         * progress bar in the user interface.
         */

        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... params) {
        /**
         * Invoked on the background thread immediately after onPreExecute()
         * finishes executing. This step is used to perform background
         * computation that can take a long time. The parameters of the
         * asynchronous task are passed to this step.
         */
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        /**
         * Invoked on the UI thread after the background computation
         * finishes. The result of the background computation is passed to
         * this step as a parameter.
         */
        super.onPostExecute(result);
    }

}
new MyAsyncClass().execute();