com.android.volley.NoConnectionError:java.io.IOException:收到的身份验证质询为null
我已经在android上实现了volley库。但是我得到了错误com.android.volley.NoConnectionError:java.io.IOException:收到的身份验证质询为null,java,android,android-volley,Java,Android,Android Volley,我已经在android上实现了volley库。但是我得到了错误com.android.volley.NoConnectionError:java.io.IOException:Received authentication challenge为null,URL rquest为http://23.89.192.247/tanker-dev/index.php/api/masuk, 这是我的代码: queue = Volley.newRequestQueue(this);
com.android.volley.NoConnectionError:java.io.IOException:Received authentication challenge为null
,URL rquest为http://23.89.192.247/tanker-dev/index.php/api/masuk
,
这是我的代码:
queue = Volley.newRequestQueue(this);
Map<String, String> jsonParams = new HashMap<String, String>();
jsonParams.put("username",user);
jsonParams.put("password", password);
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
url,
new JSONObject(jsonParams),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(SplashLoginActivity.this, ""+response,Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(SplashLoginActivity.this, ""+error,Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
headers.put("User-agent", "My useragent");
headers.put("WWW-Authenticate", "None");
return headers;
}
};
queue.add(jsonObjReq);
queue=Volley.newRequestQueue(此);
Map jsonParams=newhashmap();
jsonParams.put(“用户名”,用户);
jsonParams.put(“密码”,password);
JsonObjectRequest JSONObjectReq=新的JsonObjectRequest(Request.Method.POST,
网址,
新的JSONObject(jsonParams),
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
Toast.makeText(SplashLoginActivity.this,“+响应,Toast.LENGTH_LONG.show();
}
},new Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
Toast.makeText(SplashLoginActivity.this,“+错误,Toast.LENGTH_LONG.show();
}
}) {
@凌驾
公共映射getHeaders()引发AuthFailureError{
HashMap headers=新的HashMap();
headers.put(“内容类型”、“应用程序/json;字符集=utf-8”);
headers.put(“用户代理”、“我的用户代理”);
headers.put(“WWW-Authenticate”、“None”);
返回标题;
}
};
add(jsonObjReq);
如何修复它?对不起,我的英语…错误号是什么?很可能是401错误。。。