Android
Calls Quick Start

Quick Start

SendBird Calls enables real-time voice and video calls between users within your SendBird-integrated app. The Calls SDK for Android is used to initialize, configure, and build voice and video calling functionality into your Android application. This quick start shows a brief overview of the Calls SDK’s structure and features, then goes through the preliminary steps of implementing the Calls SDK into your own project.


Try the sample app

Our sample app demonstrates an implementation of the core features of SendBird Calls SDK. Download the app from our GitHub repository to get an idea of what you can do with the actual SDK and to get started building your own project.

Download Sample App

Note: The fastest way to see our Calls SDK in action is to build your app on top of our sample app. Make sure to change the application ID with your own when initializing the Calls SDK. Go to Create a SendBird application from your dashboard section to learn more.


How SendBird Calls SDK works with your app

SendBird Calls can only be used by your SendBird application users. When a user logs in, the user can send and receive direct calls with other users on the same SendBird application.

Direct call in the Calls SDK refers to a one-to-one call. To make a direct call, the caller first initializes a call request to the callee. The callee will receive incoming call notifications to all logged in devices. When the callee accepts the call on any of these devices, a media connection is established between the caller and callee which marks the start of a direct call.

Call-related events are delivered through call event handlers. The event handlers include onRinging(), onConnected(), onEnded(), and other event callbacks. By using event callbacks of the handlers, your app can implement appropriate responses and actions accordingly such as updating call status on the UI level.


Requirements

The minimum requirements for Calls SDK for Android are:

  • Android 4.1 (API level 16) or later
  • Java 8 or later

Install and configure the Calls SDK

If you are ready to integrate chat to your app, follow the step-by-step instructions below.

Step 1: Create a SendBird application from your dashboard

First, create your SendBird application which comprises everything required in a chat service such as users, messages, and channels.

  1. In the SendBird Dashboard, type your email and password to create a new account. You can also sign in with or sign up for a Google account.
  2. When prompted by the setup wizard, enter your organization information to manage SendBird applications.
  3. Lastly, when your dashboard home appears after completing setup, click Create App at the top-right corner for a new application. You can also create via the Platform API.

You can only integrate one SendBird application per app for your service regardless of the platforms. All users within your SendBird application can communicate with each other across all platforms. This means that your iOS, Android, and web client app users can all make and receive calls with one another without any further setup. Note that all data are limited to the scope of a single application, and users in different SendBird applications can't make and receive calls to each other.

Note: For application administrators, the SendBird dashboard provides call logs to keep track of all calls made on the application.

Step 2: Install the Calls SDK

Installing the Calls SDK is simple if you’re familiar with using external libraries or SDKs in your project. To install the Calls SDK using Gradle, add the following lines to a build.gradle file at the app level.

build.gradle
Light Color Skin
Copy
dependencies {
    implementation 'com.sendbird.sdk:sendbird-calls:0.8.1'
}

Step 3: Grant system permissions to the Calls SDK

The Calls SDK requires system permissions. These permissions allow the Calls SDK to communicate with SendBird server. It can also record audio and discover bluetooth devices. To grant system permissions, add the following lines to your AndroidManifest.xml file.

AndroidManifest.xml
Light Color Skin
Copy
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

The CAMERA and RECORD_AUDIO permissions are considered as dangerous permissions and require user agreement when your client app is first launched on a user’s device with Android 6.0 or higher.

Note: For more information about requesting app permissions, see the Android’s Request App Permissions guide.


Make your first call

The Calls SDK adds call features to your client app with a few simple steps. To make your first call, do the following steps:

Step 1: Initialize the Calls SDK in your app

First, the SendBirdCall instance must be initialized when a client app is launched. Initialization is done by using the APP_ID of your SendBird application in the dashboard. If the instance is initialized with a different APP_ID, all existing call-related data in a client app will be cleared and the SendBirdCall instance will be initialized again with the new APP_ID.

Note: The SendBirdCall.init() method must be called once across your Android client app. It is recommended to initialize the Chat SDK in the onCreate() method of the Application instance.

Light Color Skin
Copy
SendBirdCall.init(getApplicationContext(), APP_ID);

Step 2: Authenticate a user and add a registration token

Note: You can implement both the Chat and Calls SDKs to your client app. Two SDKs can work on the same SendBird application for them to share users. In this case, you can allow Calls to retrieve a list of users in the client app by using the Chat SDK’s method or Chat Platform API.

To make and receive calls, authenticate a user to SendBird server by using their user ID through the authenticate() method. To receive calls while an app is in the background or closed, a user’s registration token must be added to the server. A registration token can be added by providing it as a parameter in the authenticate() method when authenticating a user, or by using the SendBirdCall.registerPushToken() method after a user’s authentication has been completed.

Light Color Skin
Copy
// Authentication
AuthenticateParams params = new AuthenticateParams(USER_ID)
    .setAccessToken(ACCESS_TOKEN)
    .setPushToken(PUSH_TOKEN, isUnique);

SendBirdCall.authenticate(params, new AuthenticateHandler() {
    @Override
    public void onResult(User user, SendBirdException e) {
        if (e == null) {
            // The user is authenticated successfully.
        }
    }
});

Step 3: Add an event handler

Add a device-specific SendBirdCallListener event handler using the SendBirdCall.addSendBirdCallListener() method. Once the event handler is added, responding to device events such as incoming calls can be managed as shown below:

Light Color Skin
Copy
SendBirdCall.addListener(UNIQUE_HANDLER_ID, new SendBirdCallListener() {
    @Override
    public void onRinging(DirectCall call) {
    }
});

Note: If a SendBirdCallListener event handler isn’t registered, a user can't receive an onRinging callback event, thus recommended to add this handler at the initialization of the app. Also, a SendBirdCallListener event handler is automatically removed when the app closes by default.

Step 4: Make a call

Initiate a call by providing the callee’s user id into the SendBirdCall.dial() method. Use the CallOptions object to choose initial call configuration, such as audio or video capabilities, video settings, and mute settings.

Light Color Skin
Copy
DialParams params = new DialParams(CALLEE_ID);
params.setVideoCall(true);
params.setCallOptions(new CallOptions());

DirectCall call = SendBirdCall.dial(params, new DialHandler() {
    @Override
    public void onResult(DirectCall call, SendBirdException e) {
        if (e == null) {
            // The call has been created successfully.
        }
    }
});

call.setListener(new DirectCallListener() {
    @Override
    public void onEstablished(DirectCall call) {
    }

    @Override
    public void onConnected(DirectCall call) {
    }

    @Override
    public void onEnded(DirectCall call) {
    }
});

Step 5: Receive a call

To receive an incoming call, a SendBirdCallListener event handler should already be registered in the callee’s client app. Accept or decline the call using the directCall.accept() or the directCall.end() method. If the call is accepted, a media session will automatically be established by the Calls SDK.

Light Color Skin
Copy
SendBirdCall.addListener(UNIQUE_HANDLER_ID, new SendBirdCallListener() {
    @Override
    public void onRinging(DirectCall call) {
        call.setListener(new DirectCallListener() {
            @Override
            public void onEstablished(DirectCall call) {
            }

            @Override
            public void onConnected(DirectCall call) {
            }

            @Override
            public void onEnded(DirectCall call) {
            }
            
            @Override
            public void onRemoteAudioSettingsChanged(DirectCall call) {
            }
        });

        call.accept(new AcceptParams());
    }
});