Java 如何处理此错误使其正确?“方法声明无效;需要返回类型”
我如何修复这个错误,其中我得到了无效的方法声明;返回类型为必需,错误为缺少方法体或声明摘要 请帮忙。我会感激你的好意Java 如何处理此错误使其正确?“方法声明无效;需要返回类型”,java,android,android-studio,Java,Android,Android Studio,我如何修复这个错误,其中我得到了无效的方法声明;返回类型为必需,错误为缺少方法体或声明摘要 请帮忙。我会感激你的好意 private void login(final String email, final String password) { //Tag used to cancel the request String tag_string_req = "req_login"; progressDialog.setMessage("Loggin
private void login(final String email, final String password) {
//Tag used to cancel the request
String tag_string_req = "req_login";
progressDialog.setMessage("Logging in....");
progressDialog.show();
StringRequest strReq = new StringRequest(Request.Method.POST,
Utils.LOGIN_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Login Response: " + response.toString());
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
//check for error node in json
if (!error) {
//now store the user in SQLite
JSONObject user = jObj.getJSONObject("user");
String uName = user.getString("username");
String email = user.getString("email");
//Inserting row in users table
userInfo.setEmail(email);
userInfo.setUsername(uName);
session.setLoggedin(true);
startActivity(new Intent(Login.this, MainActivity.class));
finish();
} else {
//error in login, get the error message
String errorMsg = jObj.getString("error_msg");
toast(errorMsg);
}
} catch (JSONException e) {
//json error
e.printStackTrace();
toast("Json error: " + e.getMessage());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Login Error: " + error.getMessage());
toast("Unknown Error occured");
progressDialog.hide();
}
}) {
@Override
protected Map<String, String> getParams() {
//Posting parameters to login url
Map<String, String> params = new HashMap<>();
params.put("email", email);
params.put("password", password);
return params;
}
Response.Listener的右括号“}”后面缺少右括号。因此,在结尾应该至少有两个结束的花括号
//Adding request to request queue
AndroidLoginController.getInstance().addToRequestQueue(strReq, tag_string_req);
}