KOTLIN
Android voice & video call SDK (Kotlin)
Use the native Android SDK (Kotlin, Maven Central) for chat, 1:1 and group voice and video calls, and screen sharing. Calls keep working in the background with an ongoing-call notification.
Before you start
Authenticate the user in your own backend, decide whether they may enter the room, and request a short-lived RTC token. The client receives that token and never receives the App Secret.
Install
The SDK is published on Maven Central as com.devsquarelabs:rtcexpress-android. Follow the Android voice calling tutorial to build a working call app step by step. There are also tutorials for video calling and in-app chat.
// app/build.gradle.kts (repositories: google(), mavenCentral())
dependencies {
implementation("com.devsquarelabs:rtcexpress-android:0.1.6")
}Initialize and join a room
val rtc = RTCExpress(applicationContext)
rtc.init(RTCInitOptions(serverUrl, appId, userId, token, mediaMode = "auto"))
rtc.joinRoom("room-1")
rtc.callUser("user-b", video = true)Calling people in your app
A call happens inside a room: the caller must have joined it, and on Starter and Pro the person being called must be a member too. For an app where users call their contacts:
- Your backend gives each signed-in user one token without a
roomId. - After
init, join one room per contact, named from both user IDs in sorted order, for exampledm_alice__bob. Join them one at a time and wait forroomJoinedeach time. - To call Bob, join
dm_alice__bobagain (it becomes the current room), wait forroomJoined, then call. - The incoming call says whether it is voice or video (
callType): ask for camera permission only for video.
dm_<userA>__<userB> are private: only those two users can join them, so chat history and calls stay between the pair. For a single fixed room (a support chat, one meeting) create the token with that roomId instead.Group voice and video calls
Version 0.1.1 or later, on Android. After joining a room, join its group call, show one video tile per person and highlight who is speaking. Group voice needs the Starter plan; group video needs Pro.
rtc.joinVideoRoom() // or rtc.joinVoiceRoom()
override fun onMediaParticipant(roomId: String, userId: String, joined: Boolean) { /* add or remove a tile */ }
override fun onAudioLevels(levels: Map<String, Double>) { /* highlight who is speaking */ }
val tile = CallVideoView(context).apply { this.userId = "bob" } // one tile per personScreen sharing
Version 0.1.2 or later. Share the phone’s screen in a 1:1 or group call. Android shows its own “Start recording or casting?” prompt first, and a notification while sharing.
val launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK && result.data != null) rtc.startScreenShare(result.data!!)
}
rtc.checkCanShareScreen() // clear message if not in a call
launcher.launch(rtc.createScreenShareIntent())
rtc.stopScreenShare()
// Others get listener.onScreenShare(userId, active). Show the screen big:
CallVideoView(context).apply { screen = true; userId = "bob" }Needs a plan with screen sharing (Pro) and calls through the media server (mediaMode = "auto", the default). Android shows its own “Start recording or casting?” prompt first. Web users see a phone’s shared screen, and phones see a browser’s.
Calls in the background
Calls keep working when the user goes to another app or turns the screen off. During a call the SDK shows an “Ongoing call” notification with a timer: tap it to return to the app, or press Hang up. Android needs this notification for an app to keep using the microphone and camera in the background. It is on by default. Turn it off with RTCInitOptions(..., ongoingCallNotification = false) if your app shows its own.
Publishing on Google Play (target Android 14 or newer): the SDK declares foreground services of type microphone, camera and mediaProjection, so fill in the “Foreground service permissions” form in Play Console (reasons: ongoing voice/video call, and screen sharing during a call).
Production notes
Test two real devices, permission denial, network switching, background behavior, and reconnects. Record the call ID and UTC time for diagnostics.