API Reference

com.kinvey.android

Class Client.Builder<T extends User>

  • com.kinvey.android.Client.Builder<T>
  • Enclosing class:
    Client<T extends User>


    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.

    • Constructor Summary

      Constructors 
      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.
    • Constructor Detail

      • Builder

        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.

        Parameters:
        appKey - Your Kinvey Application Key
        appSecret - Your Kinvey Application Secret
        context - Your Android Application Context
        transport - HttpTransport
      • Builder

        public 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.

        Parameters:
        appKey - Your Kinvey Application Key
        appSecret - Your Kinvey Application Secret
        context - Your Android Application Context
      • Builder

        public 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.

        Parameters:
        context -
        • Your Android Application Context

        See Also:
        Kinvey Guide for initializing Client with a properties file.
      • Builder

        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.

        Parameters:
        context -
        • Your Android Application Context

        See Also:
        Kinvey Guide for initializing Client with a properties file.
      • Builder

        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.

        Parameters:
        properties -
        • InputStream of properties file

        transport -
        • custom user http transport

        context -
        • Your Android Application Context

        See Also:
        Kinvey Guide for initializing Client with a properties file.
      • Builder

        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.

        Parameters:
        properties -
        • InputStream of properties file

        context -
        • Your Android Application Context

        See Also:
        Kinvey Guide for initializing Client with a properties file.
    • Method Detail

      • setHttpRequestInitializer

        public Client.Builder<?> setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer)
      • setUserClass

        public Client.Builder<?> setUserClass(java.lang.Class<T> userClass)
      • setEncryptionKey

        public Client.Builder<?> setEncryptionKey(byte[] encryptionKey)
      • setRequestTimeout

        public Client.Builder<?> setRequestTimeout(int requestTimeout)
        Parameters:
        requestTimeout -
        • the request timeout

      • setInstanceID

        public Client.Builder<?> setInstanceID(java.lang.String instanceID)
        Parameters:
        instanceID -
      • build

        public Client<T> build()
        Returns:
        an instantiated Kinvey Android Client, which contains factory methods for accessing various functionality.
      • initUserFromCredentialStore

        public void initUserFromCredentialStore(Client<T> client)
      • setCredentialStore

        public Client.Builder<?> setCredentialStore(com.kinvey.java.auth.CredentialStore store)

        Define how credentials will be stored

        Parameters:
        store - something implementing CredentialStore interface
        Returns:
        this builder, with the new credential store set
      • setJsonFactory

        public Client.Builder<?> setJsonFactory(com.google.api.client.json.JsonFactory factory)
        Parameters:
        factory -
        • the JSON factory for this client to use

        Returns:
      • setRetrieveUserCallback

        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:

        Parameters:
        callback -
        Returns:
      • enableFCM

        public Client.Builder<?> enableFCM(boolean fcmEnabled)

        Builder method to enable FCM for the client

        Parameters:
        fcmEnabled -
        • should push use FCM, defaults to true

        Returns:
        the current instance of the builder
      • setSenderIDs

        public Client.Builder<?> setSenderIDs(java.lang.String senderID)

        Builder method to set sender ID for FCM push

        Parameters:
        senderID -
        • the senderID to register

        Returns:
        the current instance of the builder
      • setBaseUrl

        public Client.Builder<?> setBaseUrl(java.lang.String baseUrl)
      • setGcmInProduction

        public Client.Builder<?> setGcmInProduction(boolean inProduction)
      • isDeltaSetCache

        public boolean isDeltaSetCache()

        Get setting value of delta set caching

      • setDeltaSetCache

        public Client.Builder<?> setDeltaSetCache(boolean deltaSetCache)

        Set the setting for delta set cache