public static class Client.Builder<T extends User>
Create a client for interacting with Kinvey's services from an Android Activity.
All features of the library are be accessed through an instance of a client.
It is recommended to maintain a single instance of a Client
while developing with Kinvey, either in an
Activity, a Service, or an Application.
This Builder class is not thread-safe.
Modifier and Type | Class and Description |
---|---|
static class |
Builder.Build |
static class |
Builder.Companion |
Modifier and Type | Field and Description |
---|---|
static Builder.Companion |
Companion |
Constructor and Description |
---|
Builder(java.lang.String appKey,
java.lang.String appSecret,
android.content.Context context,
com.google.api.client.http.HttpTransport transport)
Use this constructor to create a AbstractClient.Builder, which can be used to build a Kinvey AbstractClient with defaults
set for the Android Operating System.
|
Builder(java.lang.String appKey,
java.lang.String appSecret,
android.content.Context context)
Use this constructor to create a AbstractClient.Builder, which can be used to build a Kinvey AbstractClient with defaults
set for the Android Operating System.
|
Builder(android.content.Context context,
com.google.api.client.http.HttpTransport transport)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults
set for the Android Operating System.
|
Builder(android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults
set for the Android Operating System.
|
Builder(java.io.InputStream properties,
com.google.api.client.http.HttpTransport transport,
android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults
set for the Android Operating System.
|
Builder(java.io.InputStream properties,
android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults
set for the Android Operating System.
|
Modifier and Type | Method and Description |
---|---|
Client<T> |
build() |
void |
build(KinveyClientBuilderCallback buildCallback)
Asynchronous Client build method
|
Client.Builder<?> |
enableFCM(boolean fcmEnabled)
Builder method to enable FCM for the client
|
void |
initUserFromCredentialStore(Client<T> client) |
boolean |
isDeltaSetCache()
Get setting value of delta set caching
|
Client.Builder<?> |
setBaseUrl(java.lang.String baseUrl) |
Client.Builder<?> |
setCredentialStore(com.kinvey.java.auth.CredentialStore store)
Define how credentials will be stored
|
Client.Builder<?> |
setDeltaSetCache(boolean deltaSetCache)
Set the setting for delta set cache
|
Client.Builder<?> |
setEncryptionKey(byte[] encryptionKey) |
Client.Builder<?> |
setGcmInProduction(boolean inProduction) |
Client.Builder<?> |
setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) |
Client.Builder<?> |
setInstanceID(java.lang.String instanceID) |
Client.Builder<?> |
setJsonFactory(com.google.api.client.json.JsonFactory factory) |
Client.Builder<?> |
setRequestTimeout(int requestTimeout) |
Client.Builder<T> |
setRetrieveUserCallback(KinveyUserCallback<com.kinvey.android.model.User> callback)
Sets a callback to be called after a client is intialized and BaseUser attributes is being retrieved.
|
Client.Builder<?> |
setSenderIDs(java.lang.String senderID)
Builder method to set sender ID for FCM push
|
Client.Builder<T> |
setUserClass(java.lang.Class<T> userClass) |
public static Builder.Companion Companion
public Builder(java.lang.String appKey, java.lang.String appSecret, android.content.Context context, com.google.api.client.http.HttpTransport transport)
Use this constructor to create a AbstractClient.Builder, which can be used to build a Kinvey AbstractClient with defaults set for the Android Operating System.
This constructor does NOT support push notification functionality. If push notifications are necessary, use a properties file and the overloaded constructor.
appKey
- Your Kinvey Application KeyappSecret
- Your Kinvey Application Secretcontext
- Your Android Application Contexttransport
- HttpTransportpublic Builder(java.lang.String appKey, java.lang.String appSecret, android.content.Context context)
Use this constructor to create a AbstractClient.Builder, which can be used to build a Kinvey AbstractClient with defaults set for the Android Operating System.
This constructor does NOT support push notification functionality. If push notifications are necessary, use a properties file and the overloaded constructor.
appKey
- Your Kinvey Application KeyappSecret
- Your Kinvey Application Secretcontext
- Your Android Application Contextpublic Builder(android.content.Context context, com.google.api.client.http.HttpTransport transport)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults set for the Android Operating System.
This constructor requires a properties file, containing configuration for your Kinvey Client. create kinvey.properties file in your assets folder according kinvey docs
This constructor provides support for push notifications.
Kinvey Guide for initializing Client with a properties file.
context
- Your Android Application Context
public Builder(android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults set for the Android Operating System.
This constructor requires a properties file, containing configuration for your Kinvey Client. create kinvey.properties file in your assets folder according kinvey docs
This constructor provides support for push notifications.
Kinvey Guide for initializing Client with a properties file.
context
- Your Android Application Context
public Builder(java.io.InputStream properties, com.google.api.client.http.HttpTransport transport, android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults set for the Android Operating System.
This constructor can get configuration for your Kinvey Client from properties file. Save this file within your Android project, and pass InputStream of that file to constructor. You can set appKey and appSecret in parameters, in this case appKey and appSecret from kinvey.properties will be ignored.
This constructor provides support for push notifications.
Kinvey Guide for initializing Client with a properties file.
properties
- InputStream of properties file
transport
- custom user http transport
context
- Your Android Application Context
public Builder(java.io.InputStream properties, android.content.Context context)
Use this constructor to create a Client.Builder, which can be used to build a Kinvey Client with defaults set for the Android Operating System.
This constructor can get configuration for your Kinvey Client from properties file. Save this file within your Android project, and pass InputStream of that file to constructor. You can set appKey and appSecret in parameters, in this case appKey and appSecret from kinvey.properties will be ignored.
This constructor provides support for push notifications.
Kinvey Guide for initializing Client with a properties file.
properties
- InputStream of properties file
context
- Your Android Application Context
public Client.Builder<?> setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer)
public Client.Builder<T> setUserClass(java.lang.Class<T> userClass)
public Client.Builder<?> setEncryptionKey(byte[] encryptionKey)
public Client.Builder<?> setRequestTimeout(int requestTimeout)
requestTimeout
- the request timeout
public Client.Builder<?> setInstanceID(java.lang.String instanceID)
instanceID
- public Client<T> build()
public void build(KinveyClientBuilderCallback buildCallback)
Asynchronous Client build method
buildCallback
- Instance of interface KinveyClientBuilderCallback
public void initUserFromCredentialStore(Client<T> client)
public Client.Builder<?> setCredentialStore(com.kinvey.java.auth.CredentialStore store)
Define how credentials will be stored
store
- something implementing CredentialStore interfacepublic Client.Builder<?> setJsonFactory(com.google.api.client.json.JsonFactory factory)
factory
- the JSON factory for this client to use
public Client.Builder<T> setRetrieveUserCallback(KinveyUserCallback<com.kinvey.android.model.User> callback)
Sets a callback to be called after a client is intialized and BaseUser attributes is being retrieved.
When a client is initialized after an initial login, the user's credentials are cached locally and used for the initialization of the client. As part of the initialization process, a background thread is spawned to retrieve up-to-date user attributes. This optional callback is called when the retrieval process is complete and passes an instance of the logged in user.
Sample Usage:
callback
- public Client.Builder<?> enableFCM(boolean fcmEnabled)
Builder method to enable FCM for the client
fcmEnabled
- should push use FCM, defaults to true
public Client.Builder<?> setSenderIDs(java.lang.String senderID)
Builder method to set sender ID for FCM push
senderID
- the senderID to register
public Client.Builder<?> setBaseUrl(java.lang.String baseUrl)
public Client.Builder<?> setGcmInProduction(boolean inProduction)
public boolean isDeltaSetCache()
Get setting value of delta set caching
public Client.Builder<?> setDeltaSetCache(boolean deltaSetCache)
Set the setting for delta set cache