Android Kotlin and Jetpack Compose video call guide (no backend needed)

Three steps to a native 1:1 call: get your App Key, install the SDK, then TitliVideo.init() and start or join a call on the Compose call screen. Then the parts the quickstart leaves for later: your own UI, background behaviour, billing, errors and optional server tokens.

What you will build

An activity that starts or joins a metered 1:1 video or voice call with only the App Key. TitliCallScreen starts the ongoing-call notification and shows the video or audio layout, a timer, the reconnecting state and the end screen. You do not need a server; the App Key is publishable, and a project key secret, if you add a server later, never goes into the app.

The native Android SDK is in beta (version 0.2.0 adds Quick mode). Requirements: Android 7.0 or later (minSdk 24) and Java 17. It wraps the open-source LiveKit Android SDK (Apache-2.0). It installs from JitPack.

On Flutter? Follow the Flutter guide instead (Android 5.0 or later). Product details: Android video calling SDK.

Prerequisites

  • A console account. Sign-up is self-serve. A new account starts with a welcome credit of ₹100 (INR accounts) or $1.20 (USD accounts), once per person or company, so your first test calls need no recharge.
  • No backend. Quick mode needs only the App Key in your app. A server of your own is optional, for production hardening.
  • An Android app for Android 7.0 or later (minSdk 24 or higher), with Java 17 and Jetpack Compose.
  • Nothing to download: Gradle fetches the SDK from JitPack.

Quick mode: add your App Key, make a call in 5 minutes

No backend needed: add your App Key in the app and start calling. A server is optional, for production hardening.

  1. Get your App Key. In the console, open Projects → Quick mode and add your app's package name (and, if you like, the SHA-256 of your signing certificate). Your App Key is shown there.
  2. Install the package from JitPack (the console download is only a fallback).
    app/build.gradle.kts
    // settings.gradle.kts: repositories { google(); mavenCentral(); maven("https://jitpack.io") }
    dependencies { implementation("com.github.titli-video-sdk:titli-video-sdk-android:0.2.0") }
  3. Init with the App Key, then start or join a call. That is all: no server, no tokens.
    MainActivity.kt
    // 1. Once, in Application.onCreate: your App Key and your own user id
    TitliVideo.init(context, appKey = "tak_…", userId = "user-42", userName = "Asha")
    
    // 2. Start a video call (suspend; call from a coroutine)
    val call = TitliVideo.startCall(type = TitliCallType.VIDEO)
    // share call.callId with the other person
    
    // 3. On the other phone
    TitliVideo.joinCall(callId)

The App Key is publishable, not a secret: it can only reach the app-facing routes, it is bound to your package name, bundle ID or website, and spend and usage caps fence it. The binding is a deterrent, not a lock (a determined attacker can copy an app's identity), so the caps are what limit the damage. For strict control, add server tokens (production hardening below). Quick mode: bindings, caps and error codes · Read the Client API (Quick mode).

Install details

build.gradle.kts
// settings.gradle.kts
repositories {
  google(); mavenCentral()
  maven("https://jitpack.io")   // this SDK, and LiveKit's audioswitch dependency
}

// app/build.gradle.kts
dependencies {
  implementation("com.github.titli-video-sdk:titli-video-sdk-android:0.2.0")
}

There is nothing to add to your manifest. The SDK's own manifest declares INTERNET, RECORD_AUDIO, CAMERA, the foreground-service types and POST_NOTIFICATIONS, plus the TitliCallService that keeps a call alive in the background, and they merge into your app. Consumer ProGuard and R8 rules ship inside the AAR.

Init and show the call screen

MyApp.kt
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        // Once: the App Key and your own id for the signed-in user. The SDK reads the package name itself.
        TitliVideo.init(this, appKey = "tak_…", userId = "user-42", userName = "Asha")
    }
}
CallActivity.kt
import com.titliapp.videosdk.TitliVideo
import com.titliapp.videosdk.TitliCall
import com.titliapp.videosdk.TitliCallType
import com.titliapp.videosdk.ui.TitliCallScreen
import com.titliapp.videosdk.ui.TitliTheme

class CallActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val callId = intent.getStringExtra("call_id") // null: start a new call
        setContent {
            var call by remember { mutableStateOf<TitliCall?>(null) }
            LaunchedEffect(Unit) {
                // Ask for RECORD_AUDIO (and CAMERA for video) before this line.
                call = if (callId == null) TitliVideo.startCall(type = TitliCallType.VIDEO) // caller, the payer
                       else TitliVideo.joinCall(callId)                                     // the other person
                // Share call?.callId with the other person (your push, your chat, or Titli Chat calls).
            }
            call?.let {
                TitliCallScreen(
                    call = it,
                    title = "Asha",
                    theme = TitliTheme(brandColor = Color(0xFF6D4AFF)),
                    onEnded = { reason -> /* analytics */ },
                    onClose = { finish() },
                )
            }
        }
    }
}

startCall and joinCall are suspend functions and return a connected TitliCall with its callId. joinCall(callId, TitliCallRole.HOST) joins as the host; TitliVideo.setUser(userId, userName) switches the signed-in user. TitliTheme takes a brandColor and an appearance (system, light or dark). All UI strings are Android resources prefixed titli_, so you can override or translate any of them in your own strings.xml.

Build your own UI (optional)

Call.kt
val call = TitliVideo.startCall(
    type = TitliCallType.VIDEO,
    options = TitliCallOptions(audioOnly = false, quality = TitliVideoQuality.AUTO),
)

lifecycleScope.launch {
    call.events.collect { e ->
        when (e) {
            is TitliCallEvent.ParticipantJoined -> {}
            is TitliCallEvent.ParticipantLeft -> {}
            is TitliCallEvent.ConnectionStateChanged -> {}
            TitliCallEvent.Reconnecting, TitliCallEvent.Reconnected -> {}
            is TitliCallEvent.CallEnded -> {} // e.reason, e.serverReason
            is TitliCallEvent.Error -> {}     // e.error
        }
    }
}

call.toggleMicrophone()      // suspend
call.toggleCamera()          // suspend
call.switchCamera()
call.toggleSpeaker()         // loudspeaker <-> earpiece
call.leave()                 // suspend
call.release()               // when your UI is gone

State is exposed as StateFlows: state (CONNECTING, CONNECTED, RECONNECTING, ENDED), participants, isMicrophoneEnabled, isCameraEnabled, isSpeakerOn, localVideoTrack, duration (display only), endReason and serverReason. Render video with TitliVideoView(call, track). Java callers can pass a TitliCallListener. The quality you request is never above the cap carried in the join token; our video is capped at 720p.

Permissions and background

  • Ask for RECORD_AUDIO (and CAMERA for video) before startCall or joinCall. (The token-based prebuilt screen in the hardening section asks for you.)
  • TitliCallService keeps the call alive in the background with an ongoing notification (timer and End). On Android 14 and later the service type is microphone, plus camera while the camera is on. It must start while your app is in the foreground, which joining does.
  • On Android 13 and later, ask for POST_NOTIFICATIONS. Without it the call still works but the notification is hidden.
  • Swiping the app away ends the call.

Audio calls

Start the call with TitliVideo.startCall(type = TitliCallType.AUDIO). Audio calls allow only the microphone, the SDK switches to audio-only by itself and the prebuilt screen shows the audio layout.

End the call and keep the receipt

Either person hangs up from the call screen. To end the call for everyone from the app, a participant calls TitliVideo.calls.end(callId). A call also ends by itself 30 seconds after everyone has left (a quick reconnect inside that window continues the same call), when its maximum length is reached (in Quick mode the project's Quick-mode call limit applies), or when your balance reaches zero.

Every ended call has an Ed25519-signed receipt you can keep for disputes. Receipts, like balance and usage reports, are read with the project key, so they are server-only; you also see every call in the console. With a server (production hardening), your backend can end any call and fetch its receipt:

terminal
curl -s -u "$AUTH" -X POST $API/v1/calls/<call_id>/end
curl -s -u "$AUTH" $API/v1/calls/<call_id>/receipt

More in Webhooks and signed receipts.

How billing applies

  • Measured on our servers. Minutes come from the media server's own join and leave events. Nothing the app reports changes the bill.
  • Per participant-minute by default: ₹0.05 for audio and ₹0.20 for video (up to 720p). A 10-minute 1:1 video call is 2 × 10 = 20 participant-minutes, so 20 × ₹0.20 = ₹4.00.
  • Billed per second, and only while at least two people are connected. A person waiting alone is not billed.
  • Free seconds for your users (first call and daily), if you set them on your account, are used before your balance.
  • Prepaid balance. A new call or token is refused with 402 when the balance cannot cover it, and live calls end when the balance runs out. It never goes below zero.
  • Quick-mode caps. With the App Key, the project's Quick-mode daily spend cap and each user's daily minutes, both set in the console, fence what one app or one user can spend.

The arithmetic, including call-minute billing, is worked through in Per-minute pricing explained. The rules are in Billing and usage and the price list is on the pricing page.

Troubleshooting

When a call ends, the SDK tells you why:

End reasonWhen
HUNG_UPThis device left the call.
ENDED_BY_SERVERThe call was ended for everyone (by a participant, or by your backend if you use one), the balance reached zero, the maximum length was reached, a Quick-mode limit was hit, or an operator ended it. The exact end_reason is on the call (TitliVideo.calls.get) and in the call.ended webhook.
REMOVEDThe call's creator (or your backend) removed this participant.
JOINED_ELSEWHEREThe same end_user_id joined from another device.
CONNECTION_LOSTThe network dropped and did not recover.
FAILED_TO_CONNECTThe join token was invalid or expired, or there was no network.

In Quick mode, every failed request raises one error type (TitliVideoError) carrying errorCode, userCode, userMessage (and the Hindi userMessageHi), a developer message and httpStatus. Show userMessage to your user as it is. The Quick-mode codes:

Error codeShown asHTTPWhen
APP_KEY_INVALIDAK-401401The App Key is missing, wrong, rotated away or disabled.
QUICK_MODE_OFFQM-403403Quick mode is switched off for the project.
APP_NOT_ALLOWEDAB-403403This package name, bundle ID, website or signing certificate is not on the App Key's list. Add it under Projects → Quick mode.
QUICK_DAILY_CAP_REACHEDQC-402402The project's Quick-mode daily spend cap is reached.
END_USER_DAILY_LIMITUM-429429This user has used today's minutes.
FORBIDDENFB-403403Acting as another user, or on a call this user is not in.
RATE_LIMITEDRL-429429Too many requests from one device or network; wait for Retry-After.

Retry only 429 (after Retry-After) and server errors (back off 1, 2 and 4 seconds); never retry the others. With server tokens, the API answers your server with { "error": { "code", "message" } }. The codes you are most likely to meet there:

HTTPCodeWhat to do
401invalid_api_key, key_revoked, key_expiredThe key ID or secret is wrong, or the key was revoked or has expired. unauthorized means no Basic auth header was sent. Check the key ID and secret on your server.
402insufficient_balance, project_cap_reachedThe balance is too low and the payer has no free seconds, or the project reached the daily spending cap set in the console.
403calls_disabled, audio_disabled, video_disabledThe account, project or call type is switched off.
409call_endedYou asked for a token on a call that has ended. Create a new call.
429concurrency_limit, rate_limitedUp to 5 calls at once per account unless support raises it; 20 requests per second per key (burst 40).

The full list is in the REST API reference and on Errors.

The native SDKs report these errors: invalidToken, tokenExpired (checked before connecting), permissionDenied (microphone or camera), connectionFailed, audioOnly (the camera was requested in an audio call) and mediaFailed. In Quick mode the SDK fetches a fresh join token itself. With server tokens, a token that expired before the user tapped Join is the most common one: mint tokens right before joining.

Production hardening (optional): server tokens

You do not need a server to start: Quick mode works with the App Key alone. Add a server when you want strict control over every call (who joins which call, for how long, in which role): keep the project key on your server and mint a short-lived join token per person there. The app uses the same SDK and hands it a token instead of the App Key. Both ways can run side by side.

The app keeps the same SDK and Compose screen; it joins with a token from your server instead of the App Key.

Create a project key

Server tokens use a project key, not the App Key. In the console, open Projects. Each project has these server values:

ValueWhere it goes
App ID (app_…)Identifies the project. Safe to log.
Key ID (tk_…) and key secret (ts_…)Your backend only. The secret is shown once.
Webhook secret (whsec_…)Your backend only, to verify webhooks.

A project can hold two active keys, so you can rotate without downtime: create the new key, deploy it, then revoke the old one. More in Authentication and tokens.

Get a token from your server

Your server keeps the API key and calls our REST API: POST /v1/calls, then POST /v1/calls/{call_id}/tokens. This complete Node endpoint has no dependencies (Node 20 or newer) and works for every platform. It returns the two values the app needs, token and livekit_url.

token-server.js
// token-server.js: POST /titli/token {"type":"video"} -> {token, livekit_url, call_id}
import http from 'node:http';
const API = 'https://api-videosdk.titliapp.com';
const AUTH = 'Basic ' + Buffer.from(`${process.env.TITLI_KEY_ID}:${process.env.TITLI_KEY_SECRET}`).toString('base64');
const titli = async (path, body) => {
  const r = await fetch(API + path, { method: 'POST', headers: { Authorization: AUTH, 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
  if (!r.ok) throw new Error(`${r.status} ${await r.text()}`);
  return r.json();
};
http.createServer(async (req, res) => {
  let raw = ''; for await (const c of req) raw += c;
  try {
    const { type = 'video' } = JSON.parse(raw || '{}');
    const me = 'user_1001'; // YOUR signed-in user's id (from your own session/auth), not from the request body
    const call = await titli('/v1/calls', { type, payer_end_user_id: me, max_duration_seconds: 1800 });
    const t = await titli(`/v1/calls/${call.id}/tokens`, { end_user_id: me, role: 'user', name: 'Ravi' });
    // Mint the other person's token the same way (role "host") and deliver it to them (push, socket, ...).
    res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ token: t.token, livekit_url: t.livekit_url, call_id: call.id }));
  } catch (e) { res.writeHead(502).end(JSON.stringify({ error: String(e.message) })); }
}).listen(8080);

Take the user's identity from your own session, never from the request body, and mint the other person's token the same way with role: "host". end_user_id is your own stable, pseudonymous id (1 to 128 characters of letters, digits and _ . : @ -). Tokens expire after 10 minutes by default (ttl_seconds); that limits when a person can join, not how long they stay. Fields and limits are in the REST API reference and Authentication and tokens.

In the app, call that endpoint. OkHttp is shown; any HTTP client works.

TitliJoin.kt
data class TitliJoin(val token: String, val livekitUrl: String)

suspend fun fetchToken(type: String): TitliJoin = withContext(Dispatchers.IO) {
    val body = """{"type":"$type"}""".toRequestBody("application/json".toMediaType())
    val req = Request.Builder().url("https://your-server.example/titli/token").post(body).build()
    OkHttpClient().newCall(req).execute().use { res ->
        val json = JSONObject(res.body!!.string())
        TitliJoin(json.getString("token"), json.getString("livekit_url"))
    }
}

Show the call screen with the token

CallActivity.kt
import com.titliapp.videosdk.ui.TitliCallScreen
import com.titliapp.videosdk.ui.TitliTheme

class CallActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val url = intent.getStringExtra("livekit_url")!!
        val token = intent.getStringExtra("token")!!
        setContent {
            TitliCallScreen(
                url = url,
                token = token,
                title = "Asha",
                theme = TitliTheme(brandColor = Color(0xFF6D4AFF)),
                onEnded = { reason -> /* analytics */ },
                onClose = { finish() },
            )
        }
    }
}

Pass the two values to the activity as intent extras after fetchToken() returns. This form of the screen asks for microphone and camera permission (with a rationale) and for notifications on Android 13 and later. To own the call object, join with TitliCall.join(context, livekitUrl, token, options). For an audio call, create it with "type": "audio" on your server (call fetchToken("audio")).

FAQ

Do I need a backend to add video calls to a Kotlin app?

No. Get your App Key from the console (Projects, then Quick mode), add your package name, install the package, init with the App Key and start a call. A server is optional: add one later for production hardening with server tokens.

Is it safe to put the App Key in my app?

Yes, it is publishable, not a secret. It can only start and join calls and use the other app-facing features, it is bound to your package name, bundle ID or website, and the spend and usage caps you set in the console fence it. The binding is a deterrent, not a lock, so the caps are what limit any damage. For strict control, add server tokens.

What does a test call cost?

Nothing out of pocket at first: a new account gets a welcome credit of ₹100 or $1.20, once per person or company. After that, video is ₹0.20 and audio ₹0.05 per participant-minute, billed per second, only while two people are connected.

When should I add server tokens?

When you want strict control over who joins which call, for how long and in which role, or when your app charges its users per minute from a wallet. Wallet debits belong on a server you trust, not in the app. Calls themselves work with the App Key alone.

Next steps

Free SDK. Pay only for the minutes you use.

Create a free account: it starts with ₹100 welcome credit, about 250 minutes of 1:1 video, so your first call needs no recharge. Questions? Message us on WhatsApp and a person replies.

Start free