Make your first call
Sendbird Calls for Android enables real-time voice and video calls for 1-to-1 calls or group calls among users within your Sendbird-integrated app. Our development kit can initialize, configure, and build voice and video calling functionality in your Android app.
Sendbird Calls supports both Direct call and Group call. Follow the guide below to make your 1-to-1 call or start a group call from scratch using Kotlin
or Java
.
Note: For a more detailed guide on building voice and video calling functionality in your app, see our Android video chat tutorial.
Requirements
The minimum requirements for Calls SDK for Android are:
Android 4.1 (API level 21) or higher
Java 8 or higher
Gradle 3.4.0 or higher
Get started
You can start making a 1-to-1 call with Direct call or create a room to start a group call with Group call by installing Sendbird Calls for Android.
Step 1 Create a project
To get started, open Android Studio and create a new project for Calls in the Project window as follows:
-
Click Start a new Android Studio project in the Welcome to Android Studio window.
-
Select Empty Activity and click Next.
-
Enter your project name in the Name field.
-
Select your language as either Java or Kotlin from the Language drop-down menu.
-
Select minimum API level as 21 or higher.
Step 2 Install using Gradle
You can install Calls for Android through Gradle
.
If using Gradle 6.7 or lower, add the following code to your root build.gradle
file:
Note: Make sure the above code block isn't added to your module
build.gradle
file.
If using Gradle 6.8 or higher, add the following to your settings.gradle
file:
Note: To learn more about updates to Gradle, see this release note.
Next, for all Gradle versions, add the dependency to your module build.gradle
file:
Note: Call SDK versions
1.5.3
or lower can be downloaded from JCenter until February 1, 2022. SDK versions higher than1.5.3
will be available on Sendbird's remote repository.
Step 3 Request to access system permissions
The Calls SDK requires system permissions. To allow the Calls SDK to record audio and discover bluetooth devices, add the following lines to the AndroidManifest.xml
file.
When launching the client app for the first time, users are required to grant runtime permissions.
For a device running Android 6.0 and up, permissions to CAMERA
and RECORD_AUDIO
are required. For a client app with targetSdkVersion
running Android 12 and up, BLUETOOTH_CONNECT
permission is required.
Note: For more information about requesting app permissions, see the Android’s Request app permissions guide.
Step 4 (Optional) Configure ProGuard to shrink code and resources
When you build your APK with minifyEnabled true
, add the following line to the module's ProGuard
rules file.
Step 5 Initialize with APP_ID
To integrate and run Sendbird Calls in your application, you need to initialize it first. Initialize the SendBirdCall
instance by using the APP_ID
of your Sendbird application, which can be found on the Sendbird Dashboard after creating an application. 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: Each Sendbird application can be integrated with a single client app. Within the same application, users can communicate with each other across all platforms, whether they are on mobile devices or on the web.
Note: The
SendBirdCall.init()
method must be called at least once in your Android client app. It is recommended to initialize the Calls SDK in theonCreate()
method of theApplication
instance.
Step 6 Authenticate a user
To make and receive a 1-to-1 call or start a group call, authenticate a user to Sendbird server by using their user ID through the authenticate()
method.
After authenticating a user, you can continue to either make a 1-to-1 call with Direct call or start a group call with Group call. Skip to Step 11 if you wish to start a group call.
Note: You can implement both the Chat and Calls SDKs to your app. Two SDKs 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 app by using the Chat SDK’s method or Chat API.
Make a 1-to-1 call
Step 7 Add a device token
You can receive a 1-to-1 call by adding the user's device token to the server. You can add the token by using the SendBirdCall.registerPushToken()
method.
Step 8 Add an event handler
You can 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:
Note: If a
SendBirdCallListener
event handler isn’t registered, a user can't receive anonRinging
callback event. Thus, this handler should be added at the initialization of the app. Also, aSendBirdCallListener
event handler is automatically removed when the app closes by default.
Step 9 Make a call
You are now ready to make your first 1-to-1 call. To make a call, provide the callee’s user ID into the SendBirdCall.dial()
method. To choose initial call configuration such as as audio or video capabilities, video settings, and mute settings, use the CallOptions
object.
Step 10 Receive a call
You can accept or decline an incoming call. To accept an incoming call, use the directCall.accept()
method. To decline a call, use the directCall.end()
method. If the call is accepted, a media session will automatically be established by the Calls SDK.
Start a group call
Step 11 Create a room
When creating your first room for a group call, you can choose either a room that supports up to 6 participants with video or a room that supports up to 100 participants with audio. When the room is created, a ROOM_ID
is generated.
-
Use the
RoomType
property to set the room type. -
Use the
createRoom()
method to create a room as shown below.
List of properties
Property name | Description |
---|---|
type | Type: RoomType |
Step 12 Enter a room
You can now enter a room and start your first group call. When you enter a room, a participant is created with a unique participant ID to represent the user in the room.
To enter a room, you must acquire the room instance from Sendbird server with the room ID. To fetch the most up-to-date room instance from Sendbird server, use the SendBirdCall.fetchRoomById()
method. Also, you can use the SendBirdCall.getCachedRoomById()
method that returns the most recently cached room instance from Sendbird Calls SDK.
Note: A user can enter the room using multiple devices or browser tabs. Entering from each device or browser tab will create a new participant.
Once the room is retrieved, call the enter()
method to enter the room.
Note: Share the room ID with other users for them to enter the room from the client app.