Add video & voice calls, call invitations (ring / accept / reject / cancel) and in-app chat to your native Android app. It speaks the exact same /signaling protocol as the Flutter and Web SDKs — so an Android user can call a Flutter or web user and vice-versa, with no backend changes.
Three modules
- Core —
com.socrits:socrits-android. The signalling client (SocritsClient) + a LiveKit media wrapper (SocritsRoom). Calls, invitations and chat — bring your own UI. - UIKit —
com.socrits:socrits-android-uikit. Prebuilt full-screen outgoing (“Calling…”) + ring + in-call screens that appear automatically. Optional; depends on Core. - FCM —
com.socrits:socrits-android-fcm. Optional offline/background ringing (the CallKit equivalent): a drop-in service that raises a full-screen incoming-call screen when the app is backgrounded or killed. Depends on UIKit.
Install
The SDK is published to the Socrits Maven repository — nothing to copy or build from source. Add the repositories (minSdk 24+, Kotlin or Java, AndroidX):
1// settings.gradle.kts2dependencyResolutionManagement {3 repositories {4 google()5 mavenCentral()6 // The Socrits SDK repository.7 maven { url = uri("https://api.socrits.com/maven") }8 // Required: LiveKit Android pulls `com.github.davidliu:audioswitch`9 // from JitPack. Without this repo the build fails to resolve it.10 maven { url = uri("https://jitpack.io") }11 }12}Then add the dependencies you need — Core is required, UIKit and FCM are optional:
1// app/build.gradle.kts2dependencies {3 implementation("com.socrits:socrits-android:0.4.0")4 implementation("com.socrits:socrits-android-uikit:0.4.0") // optional prebuilt UI5 implementation("com.socrits:socrits-android-fcm:0.4.0") // optional offline/background ring6}audioswitch transitive dependency from it. If you hit a version conflict with another dependency, pin LiveKit explicitly: implementation("io.livekit:livekit-android:2.11.0").Request the runtime camera & mic permissions before a call:
1// The Core module already declares CAMERA, RECORD_AUDIO, INTERNET, etc. (merged2// into your app manifest). Request the runtime permissions before a call:3ActivityCompat.requestPermissions(4 this,5 arrayOf(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO),6 0,7)Initialize & connect
Create the client with your Socrits base URL and connect the signalling socket. The app authenticates with a session token your backend mints — the API key is secret and never ships in the app. See Server & tokens.
1import com.socrits.Socrits23val socrits = Socrits.client(context, "https://api.socrits.com")45// Connect the signalling socket. Your backend mints the user's session token6// (POST /v1/session with your sk_live_ key) — never embed the key in the app.7socrits.connect(userToken)89// …or let the SDK fetch the token from your endpoint:10socrits.connectWithEndpoint(11 sessionEndpoint = "https://your-backend.com/socrits/session", // returns { token }12 userId = "alice",13 userName = "Alice",14)Option A — prebuilt screens (recommended)
SocritsCall.attach(...) wires the entire call flow for you. Call it once and incoming calls ring with a full-screen screen, the caller sees a “Calling…” screen, both sides open the in-call screen on accept, and everything tears down on hang-up / decline / timeout — no orchestration code.
1import com.socrits.uikit.SocritsCall2import com.socrits.model.CallMode34// One line, after you create the client — the prebuilt screens now appear by themselves.5SocritsCall.attach(context, socrits)6socrits.connect(userToken)78// Placing a call shows the caller a "Calling…" screen; an incoming call rings9// full-screen; on accept BOTH sides open the in-call screen — no orchestration code.10socrits.invite("bob", CallMode.VIDEO)Theme and toggle the controls with an optional SocritsCallConfig:
1import com.socrits.uikit.SocritsCall2import com.socrits.uikit.SocritsCallConfig34SocritsCall.attach(context, socrits, SocritsCallConfig(5 showSwitchCamera = true, // flip front/back button on video calls6 showSpeaker = true, // speaker toggle7 defaultSpeakerOn = true, // start on loudspeaker8 ringtoneOnIncoming = true, // play a ringtone while the phone rings9))1011// Your own SocritsListener still receives every event alongside the prebuilt UI.SocritsCall.attach(context, client)— one-time setup; replaces the client listener with a proxy that auto-launches the screens, while still forwarding every event to your own listener.- The in-call and ring screens ship their own vector icons (mic, camera, flip, speaker, hang up) — no reliance on platform drawables that render inconsistently across devices. (0.4.0)
SocritsCall.detach()— tear down the prebuilt UI (e.g. on logout).
Option B — your own UI
Prefer to drive navigation yourself? Set a SocritsListener and handle the events. Everything below is what Option A does under the hood.
1import com.socrits.SocritsCallback2import com.socrits.SocritsListener3import com.socrits.media.SocritsRoom4import com.socrits.model.*56socrits.listener = object : SocritsListener {7 override fun onConnected() { /* ready */ }89 override fun onIncomingCall(call: IncomingCall) {10 // show your own ring UI, then accept or reject:11 socrits.accept(call, object : SocritsCallback<SocritsRoom> {12 override fun onSuccess(room: SocritsRoom) { /* render room.room (LiveKit) */ }13 override fun onError(e: Throwable) {}14 })15 // socrits.reject(call)16 }1718 override fun onOutgoingCall(callId: String, toUserId: String, mode: CallMode) {19 // your call is now ringing — show a "Calling…" screen (added in 0.4.0)20 }21 override fun onCallConnected(room: SocritsRoom, mode: CallMode) { /* render the call */ }22 override fun onCallRejected(callId: String) { /* callee declined */ }23 override fun onCallEnded(callId: String, reason: CallEndReason) { /* close the UI */ }24 override fun onMessage(message: ChatMessage) { /* new chat message */ }25}Make & receive a call
1// Caller — ring someone. onOutgoingCall fires; the callee gets onIncomingCall.2socrits.invite("bob", CallMode.VIDEO, callback = object : SocritsCallback<String> {3 override fun onSuccess(callId: String) { /* ringing */ }4 override fun onError(e: Throwable) {}5})67// Cancel a call you placed, before it connects:8// socrits.cancel(callId)In-call controls
accept() and onCallConnected give you a SocritsRoom. Its room property is the raw LiveKit Room, so you can render video tracks and build any UI you want:
1// SocritsRoom is the media wrapper from accept() / onCallConnected.2room.toggleMicrophone() // suspend — mute / unmute3room.toggleCamera() // suspend — camera on / off4room.switchCamera() // flip front / back5room.disconnect() // leave the media room67socrits.endCall(room.callId!!) // tell the peer you hung up (vs a silent drop)89// room.room is the underlying LiveKit `Room` — use the full LiveKit Android API to10// render video tracks, observe participants, send data, etc.Offline / background ringing (FCM)
When the callee’s app is backgrounded or killed its socket is paused, so a socket onIncomingCall never arrives. The control plane instead sends a high-priority data push and the socrits-android-fcm module raises a full-screen incoming-call screen over the lock screen — the CallKit equivalent. Wire two things:
1import com.socrits.uikit.SocritsPush23// Configure once (e.g. in Application.onCreate) so the SDK can connect and join4// when the call is accepted from a cold start (app was killed):5SocritsPush.configure(6 baseUrl = "https://api.socrits.com",7 tokenProvider = { onToken -> myBackend.fetchSocritsToken { onToken(it) } }, // your /v1/session token8 userId = currentUserId,9 userName = currentUserName,10)1112// After connect(), register this device so Socrits can ring it while backgrounded/killed:13socrits.registerDevice(fcmToken, "android")Then receive the push:
1// If your app has NO FirebaseMessagingService, the bundled SocritsMessagingService2// (declared in the socrits-android-fcm manifest) handles the push automatically —3// nothing else to do.45// If you already have your own service, forward Socrits pushes to the SDK:6override fun onMessageReceived(msg: RemoteMessage) {7 if (SocritsPush.onIncomingPush(this, msg.data)) return // a Socrits incoming call8 // … your own push handling …9}google-services.json + the Google Services Gradle plugin, and should request POST_NOTIFICATIONS (Android 13+) for the ring to show. Without the key, registerDevice() stores a token Socrits can’t reach.Chat
1// Chat rides the same connection — inbound arrives on your SocritsListener.onMessage.2socrits.sendMessage(text = "hey", toUserId = "bob")3socrits.messageHistory("<conversationId>", limit = 30, callback = cb)4socrits.conversations(cb)5socrits.setTyping("<conversationId>", true)6socrits.markRead("<conversationId>")7socrits.createGroup("Team", listOf("bob", "carol"), cb) // needs Chat Pro / Enterprise tierCamera flip & whiteboard
SocritsRoom.switchCamera() flips front/back (the prebuilt in-call screen shows a flip button on video calls). For a shared drawing surface synced over the call’s data channel — no backend changes — drop in a SocritsWhiteboardView and attach it to the connected room:
1import com.socrits.uikit.SocritsWhiteboard23// Put a SocritsWhiteboardView in your in-call layout and attach it to the connected4// room — both peers draw on the same board, synced over the LiveKit data channel.5SocritsWhiteboard.attach(lifecycleScope, whiteboardView, room)VideoProcessor to a camera track you publish through the exposed LiveKit room. The processor hook is available now; a bundled on-device ML blur is not shipped yet (it needs a segmentation model and real-camera verification).