gpt4 book ai didi

java - Android Volley 错误 : com. android.volley.ClientError

转载 作者:搜寻专家 更新时间:2023-11-01 08:19:18 27 4
gpt4 key购买 nike

我想知道如何解决这个问题。已完成代码的研究和替换,但问题仍然存在。

这是我使用 volley 的代码。

private void Regist(){
loading.setVisibility(View.VISIBLE);
btn_regist.setVisibility(View.GONE);

final String name = this.name.getText().toString().trim();
final String email = this.email.getText().toString().trim();
final String password = this.password.getText().toString().trim();

StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_REGIST,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
JSONObject jsonObject = new JSONObject(response);
String success = jsonObject.getString("success");

if(success.equals("1")) {
Toast.makeText(RegisterActivity.this, "Register Success!", Toast.LENGTH_SHORT).show();
}

}catch (JSONException e) {
e.printStackTrace();
Toast.makeText(RegisterActivity.this, "Register Error!" + e.toString(), Toast.LENGTH_SHORT).show();
loading.setVisibility(View.GONE);
btn_regist.setVisibility(View.VISIBLE);

}

}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(RegisterActivity.this, "Register Error!" + error.toString(), Toast.LENGTH_SHORT).show();
loading.setVisibility(View.GONE);
btn_regist.setVisibility(View.VISIBLE);

}
})
{
@Override
protected Map<String, String> getParams()throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("name", name);
params.put("email", email);
params.put("password", password);
return super.getParams();
}
};

RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);

由于我收到“com.android.volley.ClientError”,我认为这是错误的,但如果您需要其余代码,请发表评论! enter image description here

最佳答案

替换

return super.getParams()

通过

return params;

关于java - Android Volley 错误 : com. android.volley.ClientError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53504611/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com