In my android application I want to search google for a particular query and get the response in json format using volley or retrofit. How can I implement that?
I added volley as a library and wrote below code
RequestQueue queue = Volley.newRequestQueue(this);
String url = "http://www.google.com";
JsonArrayRequest req = new JsonArrayRequest(url,
new Response.Listener<JSONArray> () {
@Override
public void onResponse(JSONArray response) {
try {
VolleyLog.v("Response:%n %s", response.toString(4));
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
});
queue.add(req);