Android SDK for Contacthub
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Version 0.9.2 beta

Contacthub Android SDK

This repository contains the official Android SDK for Contacthub.


The current version is intended as an alpha release and should not be used in a production environment, as we still reserve the right to change the underlying APIs.

Because Android applications are considered untrusted, only the APIs that can be accessed with an untrusted source have been implemented in this SDK.


  • Android 4.0.3 (API 15) or greater
  • Android Studio 2.x

How to use

Node instantiation

Every request will be performed on a Node in a Workspace. Your application will identify itself as a source and authenticate with a SOURCE_TOKEN.

Node * node = new Node.Builder().setToken('SOURCE_TOKEN').setWorkspaceId('WORKSPACE_ID').setNodeId(`NODE_ID`).create();

Create a customer

On a node you can perform several operation. One of the most common is creating a Customer.

Customer * customer = new Customer("","John","Doe");
node.createCustomer(customer, null);

The above is a fire-and-forget request. If you want to know if the operation succeeded or not, pass a ResponseCallback as the second parameter instead of null.

CustomerCallback * customerCallback = new CustomerCallback({
  public void onResponse(Response response) {
    if(response.isSuccessful()) {
      // OK
    } else {
      // Something has gone wrong!

Customer * customer = new Customer("","John","Doe");
node.createCustomer(customer, customerCallback);

Create an event for an preexisting costumer

String * customerId = customer.getObjectId();

final Event * event = new Event.Builder()
  .setDate(new Date())

node.addEvent(mCustomer, event, eventCallback);


Manually as external module

Clone the repository

Edit your project settings.gradle to include the sdk module as external module.

// Your app module
include ':app'

// ContactHub SDK module
include ':sdk'
project(':sdk').projectDir = new File(settingsDir, '../contacthub-sdk-android/sdk')

In the above it is assumed you have cloned the repo in the parent directory of your project. The settingsDir variable is defined by gradle and correspond with your project directory.

Add the sdk module to the dependancies section of your app build.gradle.

dependencies {
    // Your app dependancies
    compile ''
    compile ''
    compile ''

    // Contacthub SDK module
    compile project(':sdk')

You can also add the module as dependancy via the Project Structure dialog in Android Studio.