0
我做了一個項目,並使用REST來發送和從服務器獲取數據,我用HttpURLConnection的發送請求發送請求和響應拿到餅乾與Android凌空
然後我發現抽射,使其更易於使用,但我在使用上凌空
這裏餅乾的一個問題是我的請求函數
public void doActionJsonPost() {
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.POST, IConstants.BASE_URL + url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(response);
String msgCode = jsonObject.getString("responseCode");
} catch (JSONException e) {
LoggingHelper.verbose(e.toString());
iHttpAsync.onAsyncFailed(e.toString());
} catch (Exception e) {
LoggingHelper.verbose(e.toString());
iHttpAsync.onAsyncFailed(e.toString());
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
LoggingHelper.verbose("ERROR");
iHttpAsync.onAsyncFailed(error.getMessage());
}
}){
@Override
public byte[] getBody() throws AuthFailureError {
iHttpAsync.onAsyncProgress();
return parameters.getBytes();
}
@Override
public String getBodyContentType() {
return "application/json";
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return getAuthHeader(context);
}
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
Map<String, String> responseHeaders = response.headers;
String rawCookies = responseHeaders.get("Set-Cookie");
return super.parseNetworkResponse(response);
}
};
RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);
}
我不得不重寫parseNetworkResponse獲得headerResponse,但我看不出有餅乾
我的問題是,我怎樣才能發送和從凌空餅乾?
我在哪裏調用此方法?以及SET_COOKIE_KEY,SESSION_COOKIE,SESSION_COOKIE,COOKIE_KEY,_preferences是什麼? 對不起,我是新的凌空庫 –