UrlRequestCallbacks

public class UrlRequestCallbacks extends Object

Utility class for creating simple, convenient UrlRequest.Callback implementations for reading common types of responses.

Note that the convenience callbacks store the entire response body in memory. We do not recommend using them if it's possible to stream the response body, or if the response body sizes can cause strain on the on-device resources.

The helper callbacks come in two flavors - either the caller provides a callback to be invoked when the request finishes (successfully or not), or the caller is given a Future which completes when Cronet finishes processing the request.

Nested Class Summary

class UrlRequestCallbacks.CallbackAndResponseFuturePair<ResponseBodyT, CallbackT extends InMemoryTransformCronetCallback<ResponseBodyT>> A named pair-like structure encapsulating Cronet callbacks and associated response futures. 

Public Method Summary

Inherited Method Summary

Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Public Methods

public static ByteArrayCronetCallback forByteArrayBody (RedirectHandler redirectHandler, CronetRequestCompletionListener<byte[]> listener)

Parameters
redirectHandler
listener

public static CallbackAndResponseFuturePair<byte[], ByteArrayCronetCallback> forByteArrayBody (RedirectHandler redirectHandler)

Parameters
redirectHandler

public static JsonCronetCallback forJsonBody (RedirectHandler redirectHandler, CronetRequestCompletionListener<JSONObject> listener)

Parameters
redirectHandler
listener

public static CallbackAndResponseFuturePair<JSONObject, JsonCronetCallback> forJsonBody (RedirectHandler redirectHandler)

Parameters
redirectHandler

public static StringCronetCallback forStringBody (RedirectHandler redirectHandler, CronetRequestCompletionListener<String> listener)

Parameters
redirectHandler
listener

public static CallbackAndResponseFuturePair<String, StringCronetCallback> forStringBody (RedirectHandler redirectHandler)

Parameters
redirectHandler