UrlRequestCallbacks

Stay organized with collections Save and categorize content based on your preferences.
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

static ByteArrayCronetCallback
static CallbackAndResponseFuturePair<byte[], ByteArrayCronetCallback>
static JsonCronetCallback
forJsonBody(RedirectHandler redirectHandler, CronetRequestCompletionListener<JSONObject> listener)
static CallbackAndResponseFuturePair<JSONObject, JsonCronetCallback>
forJsonBody(RedirectHandler redirectHandler)
static StringCronetCallback
static CallbackAndResponseFuturePair<String, StringCronetCallback>
forStringBody(RedirectHandler redirectHandler)

Inherited Method Summary

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