Initializing the SDK

This document explains how to integrate the Dolby.io Communications SDK for Android into your application.

Add the Android SDK into your application

Add the following repository to your project gradle file build.gradle:

maven {
    url "https://android-sdk.voxeet.com/release"
    content {
        includeGroup "com.voxeet.sdk"
    }
}

Note: if you are looking for a beta release of the SDK, please use the following repository:

maven {
    url "https://android-sdk.voxeet.com/beta"
    content {
        includeGroup "com.voxeet.sdk"
    }
}

Add the Dolby.io Communications SDK for Android in the dependencies section of your application Gradle file app/build.gradle:

implementation "com.voxeet.sdk:sdk:${version}"

Where version is the latest version of the SDK.

Initialize the SDK

The Android Client SDK provides the initialize method to authenticate against the service using an access token. For more information, see the section titled Initialize the SDK with secure authentication.

When the application has received the access token from the customer’s server, it can initialize the SDK with:

String url = serverURL + "/api/token";

JsonObjectRequest fetchRequest = new JsonObjectRequest(
    Request.Method.GET,
    url
    null,
    new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            VoxeetSDK.initialize(token, (refreshClosure) -> {
                // The SDK calls this closure when the token needs to be refreshed.
                // See the next section for details.
            })
        }
    },
    new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            // TODO: Handle error
        }
    }
);

// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(fetchRequest);

Refresh authentication

An access token has a limited period of validity and needs periodic refreshing. In the application, the Dolby.io Communications Client SDK invokes the callback provided to the initialize call when the access token needs to be refreshed. This callback contacts the customer’s server, which in turn calls the client access token API again and returns the refreshed token, which is passed back to the Client SDK by the application.

When the application has received the refreshed access token from the customer’s server, it can pass this to the SDK with this change:

JsonObjectRequest fetchRequest = new JsonObjectRequest(
    Request.Method.GET,
    url,
    null,
    new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            VoxeetSDK.initialize(token, (refreshClosure) -> {
                // The SDK calls this closure when the token needs to be refreshed.
                // Call the SDK’s refresh closure with the new token
                refreshClosure(token);
            });
        }
    },
    new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            // TODO: Handle error
        }
    }
);

Open a session

ParticipantInfo participantInfo = new UserInfo("name", "optional id", "optional https avatar url");

VoxeetSDK.session().open(participantInfo)
    .then(new PromiseExec<Boolean, Object>() {
        @Override
        public void onCall(@Nullable Boolean result, @NonNull Solver<Object> solver) {
            // insert your logic
        }
    })
    .error(error());

Close a session

VoxeetSDK.session().close()
    .then(new PromiseExec<Boolean, Object>() {
        @Override
        public void onCall(@Nullable Boolean result, @NonNull Solver<Object> solver) {
            // insert your logic
        }
    })
    .error(error());

Result

The Dolby.io Communications SDK for Android is integrated with your application, so you have access to all SDK functionalities.

Now you can easily configure your SDK. Tutorials available in the left-side navigation panel and reference documentation guides how to do it.