com.android.volley.toolbox
Class StringRequest

java.lang.Object
  extended by com.android.volley.Request<String>
      extended by com.android.volley.toolbox.StringRequest
All Implemented Interfaces:
Comparable<Request<String>>

public class StringRequest
extends Request<String>

A canned request for retrieving the response body at a given URL as a String.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.volley.Request
Request.Method, Request.Priority
 
Constructor Summary
StringRequest(int method, String url, Response.Listener<String> listener, Response.ErrorListener errorListener)
          Creates a new request with the given method.
StringRequest(String url, Response.Listener<String> listener, Response.ErrorListener errorListener)
          Creates a new GET request.
 
Method Summary
protected  void deliverResponse(String response)
          Subclasses must implement this to perform delivery of the parsed response to their listeners.
protected  Response<String> parseNetworkResponse(NetworkResponse response)
          Subclasses must implement this to parse the raw network response and return an appropriate response type.
 
Methods inherited from class com.android.volley.Request
addMarker, cancel, compareTo, deliverError, getBody, getBodyContentType, getCacheEntry, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPostBody, getPostBodyContentType, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringRequest

public StringRequest(int method,
                     String url,
                     Response.Listener<String> listener,
                     Response.ErrorListener errorListener)
Creates a new request with the given method.

Parameters:
method - the request Method to use
url - URL to fetch the string at
listener - Listener to receive the String response
errorListener - Error listener, or null to ignore errors

StringRequest

public StringRequest(String url,
                     Response.Listener<String> listener,
                     Response.ErrorListener errorListener)
Creates a new GET request.

Parameters:
url - URL to fetch the string at
listener - Listener to receive the String response
errorListener - Error listener, or null to ignore errors
Method Detail

deliverResponse

protected void deliverResponse(String response)
Description copied from class: Request
Subclasses must implement this to perform delivery of the parsed response to their listeners. The given response is guaranteed to be non-null; responses that fail to parse are not delivered.

Specified by:
deliverResponse in class Request<String>
Parameters:
response - The parsed response returned by Request.parseNetworkResponse(NetworkResponse)

parseNetworkResponse

protected Response<String> 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 Request<String>
Parameters:
response - Response from the network
Returns:
The parsed response, or null in the case of an error