3
好吧,我是這個論壇的新成員,如果你能幫助我的話。我搜索了,但我無法找到如何添加頭到凌空的請求。我有這個代碼,我想添加接受編碼:gzip和api密鑰。我會感謝您的幫助。這裏是代碼:添加標題谷歌排球請求?
type = "cafe";
url = "https://maps.googleapis.com/maps/api/place/search/json?location=" + Global.location + "&radius=500&types=" + type + "&sensor=true&key="+placesKey;
RequestQueue rq = Volley.newRequestQueue(context);
JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
List<Review> reviews = new ArrayList<Review>();
reviews = Parsing.ParseReviews(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context, error.toString(), Toast.LENGTH_SHORT).show();
}
});
rq.add(jsonRequest);
這是一個可能的重複。看看這裏的答案:http://stackoverflow.com/questions/17049473/how-to-set-custom-header-in-volley-request – SBerg413