Sendbird Calls SDK for Android is used to initialize, configure, and build voice and video calling functionality into your Android client app. In this repository, you will find the steps you need to take before implementing the Calls SDK into a project, and a sample app which contains the code for implementing voice and video call.
Find out more about Sendbird Calls for Android on Calls for Android doc. If you need any help in resolving any issues or have questions, visit our community.
This section shows you the prerequisites you need for testing Sendbird Calls for Android sample app.
The minimum requirements for Calls SDK for Android sample are:
- Android 4.1 (API level 16) or higher
- Java 8 or higher
- Gradle 3.4.0 or higher
- Calls SDK for Android 1.5.1 or higher
For more details on installing and configuring the Calls SDK for Android, refer to Calls for Android doc.
If you would like to try the sample app specifically fit to your usage, you can do so by following the steps below.
- Login or Sign-up for an account on Sendbird Dashboard.
- Create or select a calls-enabled application on the dashboard.
- Note your Sendbird application ID for future reference.
- On the Sendbird dashboard, navigate to the Users menu.
- Create at least two new users: one as a
caller
, and the other as acallee
. - Note the
user_id
of each user for future reference.
To run the sample Android app on the Sendbird application specified earlier, your Sendbird application ID must be specified. On the sample client app’s source code, replace SAMPLE_APP_ID
with APP_ID
which you can find on your Sendbird application information.
public class BaseApplication extends Application {
...
private static final String APP_ID = "SAMPLE_APP_ID";
...
}
- Build and run the sample app on your Android device.
- Install the application onto at least two separate devices for each test user you created earlier.
- If there are no two devices available, you can use an emulator to run the application instead.
For more detail on how to build and run an Android application, refer to Android Documentation.
- Log in to the sample app on the primary device with the user ID set as the
caller
. - Log in to the sample app on the secondary device using the ID of the user set as the
callee
. Alternatively, you can also use the Calls widget found on the Calls dashboard to log in as thecallee
. - On the primary device, specify the user ID of the
callee
and initiate a call. - If all steps are followed correctly, an incoming call notification will appear on the device of the
callee
. - Reverse the roles. Initiate a call from the other device.
- If the two testing devices are near each other, use headphones to make a call to prevent audio feedback.
You can create how the current user’s local video view will show on the screen before accepting an incoming call. Follow the steps below to customize the current user’s local video view:
- Start your call activity with an incoming call ID in the
onRinging()
method within the class where you implement code for receiving a call. - Get the
DirectCall
object with the incoming call ID within theonCreate()
method of the call activity class. - Get the
SendBirdVideoView
object from thexml
file of your call activity to add a local video view. - Call the
DirectCall.setLocalVideoView()
method by using theSendBirdVideoView
object within the call activity class.
// {YourApplication}.kt
SendBirdCall.addListener("${UUID.randomUUID()}", object : SendBirdCallListener() {
override fun onInvitationReceived(invitation: RoomInvitation) {}
override fun onRinging(call: DirectCall) {
...
val intent = Intent(applicationContext, YourCallActivity::class.java)
intent.putExtra("EXTRA_INCOMING_CALL_ID", call.getCallId())
...
applicationContext.startActivity(intent)
}
})
// {YourCallActivity}.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
val callId = intent.getStringExtra("EXTRA_INCOMING_CALL_ID")
val call = SendBirdCall.getCall(callId)
...
val localVideoView = findViewById(R.id.video_view_fullscreen)
call.setLocalVideoView(localVideoView)
}
// {activity_your_call}.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<com.sendbird.calls.SendBirdVideoView
android:id="@+id/video_view_fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
</RelativeLayout>
You can use different sound effects to enhance the user experience for events that take place while using Sendbird Calls.
To add sound effects, use the SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType soundType, int resId)
method for the following events: dialing, ringing, reconnecting, and reconnected. Remember to set sound effects before the mentioned events occur. To remove sound effects, use the SendBirdCall.Options.removeDirectCallSound(SendBirdCall.SoundType soundType)
method.
// Play on a caller’s side when making a call.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.DIALING, R.raw.dialing)
// Play on a callee’s side when receiving a call.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RINGING, R.raw.ringing)
// Play when a connection is lost, but the SDK immediately attempts to reconnect.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTING, R.raw.reconnecting)
// Play when the connection is re-established.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTED, R.raw.reconnected)
To make the dialing sound play when the device is on silent or vibrate mode, use the method below.
SendBirdCall.Options.setDirectCallDialingSoundOnWhenSilentOrVibrateMode(true)
For further detail on Sendbird Calls for Android, refer to Sendbird Calls SDK for Android README.