Error:(124, 9) error: method does not override or implement a method from a supertype

我是研究僧i 提交于 2019-12-11 12:16:22

问题


I'm trying to develop a complete android login registration system with PHP and MySQL from Android. If user forget his password, a new password will be send to his e-mail. I follow this tutorial.

ForgetPassword

 email = (EditText) findViewById(R.id.forpas);

         forgetPassword.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        if ((name.getText().toString().trim().length() == 0) || (email.getText().toString().trim().length() == 0)) {
                            Toast.makeText(getApplicationContext(), "Name or E-mail cannot be null", Toast.LENGTH_LONG).show();
                            return;
                        } else {
                            NetAsync();
                        }

                    }
                });

     private class NetCheck extends AsyncTask

        {
            private ProgressDialog nDialog;

            @Override
            protected void onPreExecute(){
                super.onPreExecute();
                nDialog = new ProgressDialog(ForgetPassword.this);
                nDialog.setMessage("Loading..");
                nDialog.setTitle("Checking Network");
                nDialog.setIndeterminate(false);
                nDialog.setCancelable(true);
                nDialog.show();
            }

            @Override
            protected Boolean doInBackground(String... args){

                ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo netInfo = cm.getActiveNetworkInfo();
                if (netInfo != null && netInfo.isConnected()) {
                    try {
                        URL url = new URL("http://www.google.com");
                        HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
                        urlc.setConnectTimeout(3000);
                        urlc.connect();
                        if (urlc.getResponseCode() == 200) {
                            return true;
                        }
                    } catch (MalformedURLException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
                return false;

            }
            @Override
            protected void onPostExecute(Boolean th){

                if(th == true){
                    nDialog.dismiss();
                    new ProcessRegister().execute();
                }
                else{
                    nDialog.dismiss();
                    Toast.makeText(getApplication(),"Error in Network Connection",Toast.LENGTH_LONG).show();
                    //alert.setText("Error in Network Connection");
                }
            }
        }

        private class ProcessRegister extends AsyncTask {

            private ProgressDialog pDialog;

            String forgotpassword;
            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                forgotpassword = email.getText().toString();

                pDialog = new ProgressDialog(ForgetPassword.this);
                pDialog.setTitle("Contacting Servers");
                pDialog.setMessage("Getting Data ...");
                pDialog.setIndeterminate(false);
                pDialog.setCancelable(true);
                pDialog.show();
            }

            @Override
            protected JSONObject doInBackground(String... args) {

                UserFunction userFunction = new UserFunction();
                JSONObject json = userFunction.forPass(forgotpassword);
                return json;

            }

            @Override
            protected void onPostExecute(JSONObject json) {
                /**
                 * Checks if the Password Change Process is sucesss
                 **/
               try {
                    if (json.getString(KEY_SUCCESS) != null) {
                        //alert.setText("");
                        String res = json.getString(KEY_SUCCESS);
                        String red = json.getString(KEY_ERROR);

                        if(Integer.parseInt(res) == 1){
                            pDialog.dismiss();
                          //  alert.setText("A recovery email is sent to you, see it for more details.");
                            Toast.makeText(getApplication(),"A recovery email is sent to you, see it for more details",Toast.LENGTH_LONG).show();

                        }
                        else {
                            Toast.makeText(getApplication(),"Error",Toast.LENGTH_LONG).show();
                        }
                    }}
                catch (JSONException e) {
                    e.printStackTrace();

                }
            }}

Error

Error:(108, 13) error: ForgetPassword.NetCheck is not abstract and
 does not override abstract method doInBackground(Object...) in
 AsyncTask Error:(124, 9) error: method does not override or implement
 a method from a supertype Error:(164, 13) error:
 ForgetPassword.ProcessRegister is not abstract and does not override
 abstract method doInBackground(Object...) in AsyncTask

回答1:


You haven't provided any types for AsyncTask when declaring NetCheck, but are trying to override doInBackground(String... args) , change it to:

private class NetCheck extends AsyncTask<String, Integer, Boolean>

likewise change the declaration of ProcessRegister to:

private class ProcessRegister extends AsyncTask<String, Integer, JSONObject>

Check the docs here for more info



来源:https://stackoverflow.com/questions/35064965/error124-9-error-method-does-not-override-or-implement-a-method-from-a-supe

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