-
Notifications
You must be signed in to change notification settings - Fork 0
JSON array request
Sarawut Popadcha edited this page May 11, 2017
·
5 revisions
In VolleyRequest.class we have a GET method call
VolleyRequest.getArrayRequest(String url, VolleyResponseListener listener);
We can make a json array request by the sample code below and Endpoints.GET_JSON_ARRAY_URL is your url that return JSON array.
VolleyRequest.getArrayRequest(Endpoints.GET_JSON_ARRAY_URL, new VolleyResponseListener() {
@Override
public void onError(final VolleyError error) {
// Handle error request here
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "_error response " + error.getMessage());
}
});
}
@Override
public void onResponse(Object response) {
if (response instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) response;
// Parse your JSON response here.
Log.d(TAG, "_response json array " + jsonArray.toString());
}
}
@Override
public void onNetworkResponse(final NetworkResponse response) {
// Handle network response here.
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "_network response code " + response.statusCode);
}
});
}
});