【问题标题】:Error:(124, 9) error: method does not override or implement a method from a supertype错误:(124, 9) 错误:方法没有覆盖或实现超类型中的方法
【发布时间】:2016-05-06 00:48:49
【问题描述】:

我正在尝试使用来自 Android 的 PHP 和 MySQL 开发一个完整的 android 登录注册系统。如果用户忘记密码,新密码将发送到他的电子邮箱。我关注这个tutorial

忘记密码

 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

【问题讨论】:

    标签: java android mysql json overriding


    【解决方案1】:

    您在声明NetCheck 时没有为AsyncTask 提供任何类型,但正在尝试覆盖doInBackground(String... args),请将其更改为:

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

    同样将ProcessRegister的声明改为:

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

    查看文档here 了解更多信息

    【讨论】:

    • np 很高兴我能帮上忙 :)
    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 2019-06-01
    • 2013-04-22
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    相关资源
    最近更新 更多