public static class

Client.Builder

extends AbstractClient.Builder
java.lang.Object
   ↳ com.kinvey.java.core.AbstractKinveyClient.Builder
     ↳ com.kinvey.java.core.AbstractKinveyJsonClient.Builder
       ↳ com.kinvey.java.AbstractClient.Builder
         ↳ com.kinvey.android.Client.Builder

Class Overview

Create a client for interacting with Kinvey's services from an Android Activity.

 Client myClient =  new Client.Builder(appKey, appSecret, getContext()).build();
 
 
 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.

Summary

Public Constructors
Client.Builder(String appKey, String appSecret, 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.
Client.Builder(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.
Public Methods
Client build()
void build(KinveyClientBuilderCallback buildCallback)
Asynchronous Client build method

Client.Builder enableGCM(boolean gcmEnabled)
Builder method to enable GCM for the client
Client.Builder setCredentialStore(CredentialStore store)
Define how credentials will be stored
Client.Builder setGcmInProduction(boolean inProduction)
Client.Builder setJsonFactory(JsonFactory factory)
Client.Builder setRetrieveUserCallback(KinveyUserCallback callback)
Sets a callback to be called after a client is intialized and User attributes is being retrieved.
Client.Builder setSenderIDs(String senderID)
Builder method to set sender ID for GCM push
Client.Builder setUserClass(Class userClass)
[Expand]
Inherited Methods
From class com.kinvey.java.AbstractClient.Builder
From class com.kinvey.java.core.AbstractKinveyJsonClient.Builder
From class com.kinvey.java.core.AbstractKinveyClient.Builder
From class java.lang.Object

Public Constructors

public Client.Builder (String appKey, String appSecret, 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.

Parameters
appKey Your Kinvey Application Key
appSecret Your Kinvey Application Secret
context Your Android Application Context

public Client.Builder (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. Save this file within your Android project, at: assets/kinvey.properties

This constructor provides support for push notifications.

Kinvey Guide for initializing Client with a properties file.

Parameters
context - Your Android Application Context

Public Methods

public Client build ()

Returns
  • an instantiated Kinvey Android Client, which contains factory methods for accessing various functionality.

public void build (KinveyClientBuilderCallback buildCallback)

Asynchronous Client build method

Parameters
buildCallback Instance of {@link: KinveyClientBuilderCallback}

public Client.Builder enableGCM (boolean gcmEnabled)

Builder method to enable GCM for the client

Parameters
gcmEnabled - should push use GCM, defaults to true
Returns
  • the current instance of the builder

public Client.Builder setCredentialStore (CredentialStore store)

Define how credentials will be stored

Parameters
store something implpemting CredentialStore interface
Returns
  • this builder, with the new credential store set

public Client.Builder setGcmInProduction (boolean inProduction)

public Client.Builder setJsonFactory (JsonFactory factory)

Parameters
factory - the JSON factory for this client to use

public Client.Builder setRetrieveUserCallback (KinveyUserCallback callback)

Sets a callback to be called after a client is intialized and User attributes is being retrieved.

When a client is intialized 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:

 Client myClient = Client.Builder(this)
                    .setRetrieveUserCallback(new KinveyUserCallback() {
                public void onFailure(Throwable t) {
                    CharSequence text = "Error retrieving user attributes.";
                    Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
                

                public void onSuccess(User u) {
                    CharSequence text = "Retrieved up-to-date data for " + u.getUserName() + ".";
                    Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
                }
            }).build();
         }
 
>

public Client.Builder setSenderIDs (String senderID)

Builder method to set sender ID for GCM push

Parameters
senderID - the senderID to register
Returns
  • the current instance of the builder

public Client.Builder setUserClass (Class userClass)