公共类 MainActivity 扩展 AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setcontentview(r.layout.activity_main);
RequestQueue queue = Volley.newRequestQueue(this);
String url = "https://developers.zomato.com/api/v2.1/search?&lat=27&lon=153";
JsonObjectRequest postRequest = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// response
Log.d("Response", response.toString());
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
Log.d("ERROR", "error => " + error.toString());
}
}
) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("user-key", "55a1d18014dd0c0dac534c02598a3368");
params.put("Accept", "application/json");
return params;
}
};
queue.add(postRequest);
}
>
但我得到了所有不在附近的餐馆,请告诉我如何在应用程序中列出响应。