com.android.volley.toolbox
Class JsonObjectRequest
java.lang.Object
com.android.volley.Request<T>
com.android.volley.toolbox.JsonRequest<JSONObject>
com.android.volley.toolbox.JsonObjectRequest
- All Implemented Interfaces:
- Comparable<Request<JSONObject>>
public class JsonObjectRequest
- extends JsonRequest<JSONObject>
A request for retrieving a JSONObject
response body at a given URL, allowing for an
optional JSONObject
to be passed in as part of the request body.
Methods inherited from class com.android.volley.Request |
addMarker, cancel, compareTo, deliverError, getCacheEntry, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toString |
JsonObjectRequest
public JsonObjectRequest(int method,
String url,
JSONObject jsonRequest,
Response.Listener<JSONObject> listener,
Response.ErrorListener errorListener)
- Creates a new request.
- Parameters:
method
- the HTTP method to useurl
- URL to fetch the JSON fromjsonRequest
- A JSONObject
to post with the request. Null is allowed and
indicates no parameters will be posted along with request.listener
- Listener to receive the JSON responseerrorListener
- Error listener, or null to ignore errors.
JsonObjectRequest
public JsonObjectRequest(String url,
JSONObject jsonRequest,
Response.Listener<JSONObject> listener,
Response.ErrorListener errorListener)
- Constructor which defaults to
GET
if jsonRequest
is
null
, POST
otherwise.
- See Also:
#JsonObjectRequest(int, String, JSONObject, Listener, ErrorListener)
parseNetworkResponse
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response)
- Description copied from class:
Request
- Subclasses must implement this to parse the raw network response
and return an appropriate response type. This method will be
called from a worker thread. The response will not be delivered
if you return null.
- Specified by:
parseNetworkResponse
in class JsonRequest<JSONObject>
- Parameters:
response
- Response from the network
- Returns:
- The parsed response, or null in the case of an error