Created
October 6, 2014 16:02
-
-
Save msomu/5cabaeb6aac62c93d2be to your computer and use it in GitHub Desktop.
Making JSON object Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tag used to cancel the request | |
String tag_json_obj = "json_obj_req"; | |
String url = "http://api.androidhive.info/volley/person_object.json"; | |
final ProgressDialog pDialog = new ProgressDialog(this); | |
pDialog.setMessage("Loading..."); | |
pDialog.show(); | |
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, | |
url, null, | |
new Response.Listener<JSONObject>() { | |
@Override | |
public void onResponse(JSONObject response) { | |
Log.d("Volley:", response.toString()); | |
pDialog.hide(); | |
} | |
}, new Response.ErrorListener() { | |
@Override | |
public void onErrorResponse(VolleyError error) { | |
VolleyLog.d("Volley:", "Error: " + error.getMessage()); | |
// hide the progress dialog | |
pDialog.hide(); | |
} | |
}); | |
// Adding request to request queue | |
AppController.getInstance().addToRequestQueue(jsonObjReq, tag_json_obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment