public class HttpAccess
extends java.lang.Object
RestClient
and OAuth2. This class watches network changes as well.| Modifier and Type | Class and Description |
|---|---|
static class |
HttpAccess.NoNetworkException
Exception thrown if the device is offline, during an attempted HTTP call.
|
static class |
HttpAccess.UserAgentInterceptor
Interceptor that adds user agent header
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECT_TIMEOUT |
static HttpAccess |
DEFAULT |
static int |
READ_TIMEOUT |
| Constructor and Description |
|---|
HttpAccess(Context app,
java.lang.String userAgent)
Parameterized constructor.
|
| Modifier and Type | Method and Description |
|---|---|
OkHttpClient.Builder |
createNewClientBuilder()
Creates a new OkHttp Client Builder with appropriate connection spec
and user agent interceptor.
|
OkHttpClient |
getOkHttpClient() |
OkHttpClient.Builder |
getOkHttpClientBuilder()
Deprecated.
To be removed in 14.0. Please use
createNewClientBuilder() instead. |
OkHttpClient.Builder |
getUnauthenticatedOkHttpBuilder()
Deprecated.
To be removed in 14.0. Please use
createNewClientBuilder() instead. |
java.lang.String |
getUserAgent()
Returns the current user agent.
|
boolean |
hasNetwork()
Returns the status of network connectivity.
|
static void |
init(Context app)
Initializes HttpAccess.
|
public static final int CONNECT_TIMEOUT
public static final int READ_TIMEOUT
public static HttpAccess DEFAULT
public HttpAccess(Context app,
java.lang.String userAgent)
app - Reference to the application.userAgent - The user agent to be used with requests.public static void init(Context app)
@Deprecated public OkHttpClient.Builder getOkHttpClientBuilder()
createNewClientBuilder() instead.@Deprecated public OkHttpClient.Builder getUnauthenticatedOkHttpBuilder()
createNewClientBuilder() instead.public OkHttpClient.Builder createNewClientBuilder()
public OkHttpClient getOkHttpClient()
public boolean hasNetwork()
public java.lang.String getUserAgent()