1
我使用齊射爲登錄功能,但我得到意外的響應代碼400爲https。 它適用於wifi,但不適用於蜂窩網絡,而且問題只發生在選定的手機型號上。下面我粘貼了我的代碼。公共無效LoginRequest(最終的字符串用戶名,最終的字符串密碼,最終的ActionResponse成功,最終的行動錯誤){ RequestQueue隊列= MVolleyRequests.getInstance(mContext).getRequestQueue();Android Volley意外的響應代碼400
StringRequest sr = new StringRequest(com.android.volley.Request.Method.POST,LOGIN_URL,
new Listener<String>() {
@Override
public void onResponse(String response) {
success.action(MError.getError(Integer.parseInt(response)));
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
err.action();
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("id", username);
params.put("pwd", password);
params.put("version", "2.5");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
return params;
}
};
sr.setRetryPolicy(new DefaultRetryPolicy(
60000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
MVolleyRequests.getInstance(mContext).addToRequestQueue(sr);
}
你打給哪個網址? – 2014-10-07 14:09:37
@ A.S。它是一個https鏈接 – 2014-10-07 15:12:30