Suggestions

close search

OpenTok Android SDK

The OpenTok Android SDK lets you use OpenTok-powered video sessions in apps you build for Android devices.
API referenceDownloadTutorialsSamplesRelease Notes

This page covers the following topics:


Overview

All OpenTok applications are composed of two parts:

The client SDK for building Android apps is the OpenTok Android SDK, which provides most of the core functionality for your app, including:

Client SDKs are also available for iOS and web. All OpenTok client SDKs can interact with one another.

You can learn more about the basics of OpenTok clients, servers, sessions, and more on the OpenTok Basics page.

Building with the OpenTok Android SDK

The best way to learn how to use the OpenTok Android SDK is to follow the OpenTok Basic Video Chat tutorial:

Start tutorial

Once you understand the basics of building with the OpenTok Android SDK, you can get more detailed information and learn how to customize your application with the OpenTok developer guides. To investigate specific API classes and methods, see the OpenTok Android SDK API reference.

Code samples

For sample code, visit our opentok-android-sdk-samples repo on GitHub.

Interoperability

Apps written with the OpenTok Android SDK 2.12.1 can interoperate with OpenTok written with version 2.10+ of the OpenTok client SDKs:

Installation

The library (an aar file) is included in the root of the SDK bundle.

A Maven version is available at https://bintray.com/tokbox/maven/opentok-android-sdk. The artifact ID is "opentok-android-sdk". For more information, see Creating your own app using the OpenTok Android SDK.

Android 2.13 Beta Build - The current 2.12 release of the OpenTok Android SDK does not subscribe to H.264 streams, which means does not interoperate with OpenTok Safari projects. If you would like to test Android with H.264 streams, download the OpenTok Android SDK 2.13 beta build. This version adds H.264 support on the following reference devices: Samsung Galaxy S6, S7 and S8, Huawei Honor 8, and Google Pixel.

Developer and client requirements

The OpenTok Android SDK supports one published audio-video stream, one subscribed audio-video stream, and up to five additional subscribed audio-only streams simultaneously (this is the baseline support on a Samsung Galaxy S3). To connect more than two clients in a session using the OpenTok Android SDK, create a session that uses the OpenTok Media Router (a session with the media mode set to routed). See The OpenTok Media Router and media modes.

The SDK is supported on high-speed Wi-Fi and 4G LTE networks.

The OpenTok Android SDK is supported on armeabi, armeabi-v7a, armeabi64-v8a, and x86 architectures.

The OpenTok Android SDK works with any Android 4.1+ device (Jelly Bean, API Level 16) that has a camera (for publishing video) and adequate CPU and memory support.

Creating your own app using the OpenTok Android SDK

The library is provided in the opentok-android-sdk-2.12.1.aar file. You no longer need to include architecture-dependent .so files (which was required in previous versions). This file is included in the root of the SDK package. Place the aar file into your project in Android Studio. Then modify the gradle file for your project to reference the aar file.

A Maven version is available at https://bintray.com/tokbox/maven/opentok-android-sdk. The artifact ID is "opentok-android-sdk". Modify your app to download the OpenTok Android SDK from http://tokbox.bintray.com/maven. For example:

  1. Edit the build.gradle for your project and add the following code snippet to the allprojects/repositories section:

    maven { url "http://tokbox.bintray.com/maven" }

  2. Modify build.gradle for your module and add the following code snippet to the 'dependencies' section:

    compile 'com.opentok.android:opentok-android-sdk:2.12.1'

Your app needs to use a session ID and token generated with your OpenTok API key, which you can get by logging into your TokBox account.

For test purposes, you can generate a session ID and token by logging into your TokBox account. For a production app, generate unique tokens (and session IDs, if you need to support multiple sessions) using the OpenTok server-side libraries.

Permissions

The OpenTok Android SDK uses following permissions:

android.permission.CAMERA
android.permission.INTERNET
android.permission.RECORD_AUDIO
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.BLUETOOTH
android.permission.BROADCAST_STICKY

You do not need to add these to your app manifest. The OpenTok SDK adds them automatically. However, if you use Android 21+, certain permissions require you to prompt the user.