Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误声明类必须实现已存在的方法_Java_Android - Fatal编程技术网

Java 错误声明类必须实现已存在的方法

Java 错误声明类必须实现已存在的方法,java,android,Java,Android,我已经查看了其他线程,但它们对我来说根本不起作用 我不熟悉Java和Android开发。我正在尝试登录我的Android应用程序,所以我试着按照在线教程进行操作,然后按照我希望的方式进行调整。所以我在整个项目中都会遇到错误,它们都是一样的。在网站上,它说它工作得很好,所以我不知道我在做什么 那么,现在来看看错误 类“NetCheck”必须声明为抽象类,或在“AsyncTask”中实现抽象方法“doInBackground(params…) @Netcheck类中的重写(除onPreExecu

我已经查看了其他线程,但它们对我来说根本不起作用

我不熟悉Java和Android开发。我正在尝试登录我的Android应用程序,所以我试着按照在线教程进行操作,然后按照我希望的方式进行调整。所以我在整个项目中都会遇到错误,它们都是一样的。在网站上,它说它工作得很好,所以我不知道我在做什么

那么,现在来看看错误

  • 类“NetCheck”必须声明为抽象类,或在“AsyncTask”中实现抽象方法“doInBackground(params…)
@Netcheck类中的重写(除onPreExecute之外的所有重写)会出现以下错误:方法不会重写超类中的方法

类“ProcessRegister”必须声明为抽象,或在“AsyncTask”中实现抽象方法“doInBackground(params…)

@ProcessRegister类中的Overide出现错误:方法未重写超类中的方法。除onPreExecute之外,所有@overrides都会给出错误

在查看了其他帖子后,它说要确保这些方法是公开的或受保护的。他们是谁,另一个说要检查拼写。不过我觉得一切都很好,除非我错过了什么。有人能帮我一下吗!谢谢

import android.app.Activity;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.drm.ProcessedData;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import wishlist.com.gimme.library.UserFunctions;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class PasswordReset extends Activity {

private static String KEY_SUCCESS = "success";
private static String KEY_ERROR = "error";

EditText email;
TextView alert;
Button resetpass;

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.passwordreset);

    Button login = (Button) findViewById(R.id.bktolog);
    login.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), Login.class);
            startActivityForResult(myIntent, 0);
            finish();
        }

    });

    email = (EditText) findViewById(R.id.forpas);
    alert = (TextView) findViewById(R.id.alert);
    resetpass = (Button) findViewById(R.id.respass);
    resetpass.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            NetAsync(view);

        }

    });}

private class NetCheck extends AsyncTask

{
    private ProgressDialog nDialog;

    @Override
    protected void onPreExecute(){
        super.onPreExecute();
        nDialog = new ProgressDialog(PasswordReset.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();
            alert.setText("Error in Network Connection");
        }
    }
}

protected class ProcessRegister extends AsyncTask {

    private ProgressDialog pDialog;

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

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

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

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

    }


    protected void onProgressUpdate(Integer... args) {

    }

    @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.");

                }
                else if (Integer.parseInt(red) == 2)
                {    pDialog.dismiss();
                    alert.setText("Your email does not exist in our database.");
                }
                else {
                    pDialog.dismiss();
                    alert.setText("Error occured in changing Password");
                }

                }}
            catch (JSONException e) {
                e.printStackTrace();

            }
        }}
    public void NetAsync(View view){
        new NetCheck().execute();
    }
}
如果您查看,您将看到它表示为:

android.os.AsyncTask<Params, Progress, Result>
您的实现缺少泛型的数据类型

为此,改变:

private class NetCheck extends AsyncTask
致:

致:

受保护类ProcessRegister扩展异步任务

Integer
是因为您正在将
onProgressUpdate()
实现为接受一个
Integer
,尽管您似乎没有使用它。

您的
AsyncTask
需要这样,这取决于您需要或正在做什么:
AsyncTask
如果您有不同的问题,请提出新问题。不要试图把一个问题变成另一个问题。我看了java文档,看到了,但不确定是不是真的。谢谢你的详细描述,这真的很有帮助,我真的理解它!我在另一个java文件字符串电子邮件中遇到错误;DatabaseHandler db=新的DatabaseHandler(getApplicationContext());HashMap用户=新建HashMap();user=db.getUserDetails();email=user.get(“email”);我得到一个错误:需要不兼容的类型:Java.Lang.String找到:Java.Lang.Object/电子邮件是字符串,为什么它要查找对象?
private class NetCheck extends AsyncTask
private class NetCheck extends AsyncTask<String, Void, Boolean>
protected class ProcessRegister extends AsyncTask
protected class ProcessRegister extends AsyncTask<String, Integer, JSONObject>