Skip to Content
LYNKORIADocs

Android SDK

Install and use the native Kotlin SDK for calls, livestreams, messaging and push.

Two artifacts, published to Maven Central (not yet released; see package publishing):

ArtifactContents
io.lynkoria:lynkoria-corePure Kotlin: LynkoriaClient (messaging, presence, typing, call signals, push registration), push payload parser
io.lynkoria:lynkoria-androidLiveKit calls (LynkoriaCall), permissions, incoming-call notifications, lifecycle binding

Requirements: minSdk 24, compileSdk 36, Java 17 bytecode, Kotlin 2.4. lynkoria-android depends on io.livekit:livekit-android:2.30.0 and OkHttp 4.12 (the version LiveKit uses).

dependencies {
    implementation("io.lynkoria:lynkoria-android:0.1.0")
}

Messaging

val client = LynkoriaClient(LynkoriaConfig(
    baseUrl = "https://api.lynkoria.com",
    tokenProvider = { TokenResult(myBackend.lynkoriaMessagingToken()) }, // never a service key
))
client.bindToProcessLifecycle() // connect in foreground, disconnect in background

lifecycleScope.launch {
    client.history(conversationId)            // also starts gap tracking
    client.messageEvents.collect { event -> render(event) }
}
client.send(conversationId, "Hello")          // idempotent; reuse clientMessageId to retry

connectionState is a StateFlow; presenceEvents, typingEvents, readEvents, callSignals and errors are SharedFlows. Errors are LynkoriaException with the contract code.

Calls and livestreams

val missing = LynkoriaPermissions.missing(this, LynkoriaPermissions.forCall(video = true))
// request `missing` with ActivityResultContracts.RequestMultiplePermissions, then:
val call = LynkoriaCall.join(context, myBackend.joinCall(callId)) // JoinCredentials(url, token)
call.setMicrophoneEnabled(true)
call.setCameraEnabled(true)
call.state.collect { /* CONNECTING, CONNECTED, RECONNECTING, DISCONNECTED */ }
call.leave()

Render video with LiveKit's TextureViewRenderer: call.room.initVideoRenderer(view) then track.addRenderer(view). The sample module shows a Jetpack Compose screen with AndroidView.

Screen share: launch MediaProjectionManager.createScreenCaptureIntent(), then call.startScreenShare(resultData). LiveKit runs the mediaProjection foreground service.

Calls in the background: pass ongoingNotification to keep the microphone and camera running when the user leaves the app. Android stops capture for background apps unless a foreground service of the microphone/camera type runs; the SDK starts LynkoriaCallService (types limited to the permissions actually granted) when the call connects and stops it on leave() or disconnect. The notification has a hang-up action.

val call = LynkoriaCall.join(
    context,
    myBackend.joinCall(callId),
    ongoingNotification = OngoingCallNotification(smallIcon = R.drawable.ic_call, callActivity = CallActivity::class.java),
)

The library declares FOREGROUND_SERVICE_MICROPHONE and FOREGROUND_SERVICE_CAMERA; declare these foreground service uses in the Play Console.

Audio routing: call.audioDevices() and call.selectAudioDevice(name) (speaker, earpiece, wired, Bluetooth via AudioSwitch). Bluetooth needs BLUETOOTH_CONNECT on Android 12+.

Push and incoming calls

class Messaging : FirebaseMessagingService() {
    override fun onNewToken(token: String) {
        scope.launch { client.registerPushToken("fcm", token, packageName) }
    }
    override fun onMessageReceived(message: RemoteMessage) {
        if (!LynkoriaNotifications.handle(this, message.data)) handleOwnPush(message)
    }
}
// Application.onCreate
LynkoriaNotifications.install(this, IncomingCallConfig(CallActivity::class.java, R.drawable.ic_call,
    onDecline = { ctx, callId -> myBackend.decline(callId) }))

Incoming calls show a CallStyle notification with a full-screen intent on the lynkoria_calls channel. A call_cancelled push stops ringing and posts a missed-call notification. On Android 13+ request POST_NOTIFICATIONS; on Android 14+ USE_FULL_SCREEN_INTENT is granted by default only to calling apps.

Limitations and troubleshooting

  • One LynkoriaCall per process is the supported model.
  • Models (Message, Conversation, LynkoriaPush.IncomingCall, …) compare by value but are not data classes: there is no copy() or destructuring, so new fields can be added in minor releases without breaking compiled apps. Build modified values with the constructor and named arguments. They depend on the small poko-annotations artifact.
  • Battery optimization and OEM background restrictions can delay FCM; high-priority data messages are used for calls.
  • If the socket never connects, check that the backend token is valid (errors emits unauthorized) and that the device has network access to the API host.

Verification

lynkoria-core unit tests and an integration test against the local API pass (realtime delivery, idempotent send, gap recovery after disconnect, non-member denial). lynkoria-core runs its integration test against a real API in CI (scripts/native-integration.sh) and has a binary-compatibility check (api/lynkoria-core.api, ./gradlew checkKotlinAbi). lynkoria-android and sample compile and pass Android lint with ./gradlew build (compileSdk 37, livekit-android 2.30.0). livekit-android pulls audioswitch from JitPack, so apps add maven("https://jitpack.io") (ideally restricted to com.github.davidliu, as in sdks/android/settings.gradle.kts). No instrumentation or device tests have run.

On this page