簡體   English   中英

錯誤:(124,9)錯誤:方法未覆蓋或從超類型實現方法

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

我正在嘗試使用來自Android的PHP和MySQL開發一個完整的android登錄注冊系統。 如果用戶忘記了密碼,新密碼將發送到他的電子郵件中。 我遵循本教程

忘記密碼

 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:(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

聲明NetCheck ,您沒有提供AsyncTask任何類型,但嘗試覆蓋doInBackground(String... args) ,將其更改為:

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

同樣,將ProcessRegister的聲明更改為:

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

此處查看文檔以獲取更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM