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 (
minSdk24 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.
- 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.
- 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") } - 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
// 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
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")
}
}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)
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 goneState 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(andCAMERAfor video) beforestartCallorjoinCall. (The token-based prebuilt screen in the hardening section asks for you.) TitliCallServicekeeps the call alive in the background with an ongoing notification (timer and End). On Android 14 and later the service type ismicrophone, pluscamerawhile 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:
curl -s -u "$AUTH" -X POST $API/v1/calls/<call_id>/end
curl -s -u "$AUTH" $API/v1/calls/<call_id>/receiptMore 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
402when 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 reason | When |
|---|---|
HUNG_UP | This device left the call. |
ENDED_BY_SERVER | The 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. |
REMOVED | The call's creator (or your backend) removed this participant. |
JOINED_ELSEWHERE | The same end_user_id joined from another device. |
CONNECTION_LOST | The network dropped and did not recover. |
FAILED_TO_CONNECT | The 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 code | Shown as | HTTP | When |
|---|---|---|---|
APP_KEY_INVALID | AK-401 | 401 | The App Key is missing, wrong, rotated away or disabled. |
QUICK_MODE_OFF | QM-403 | 403 | Quick mode is switched off for the project. |
APP_NOT_ALLOWED | AB-403 | 403 | This 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_REACHED | QC-402 | 402 | The project's Quick-mode daily spend cap is reached. |
END_USER_DAILY_LIMIT | UM-429 | 429 | This user has used today's minutes. |
FORBIDDEN | FB-403 | 403 | Acting as another user, or on a call this user is not in. |
RATE_LIMITED | RL-429 | 429 | Too 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:
| HTTP | Code | What to do |
|---|---|---|
401 | invalid_api_key, key_revoked, key_expired | The 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. |
402 | insufficient_balance, project_cap_reached | The balance is too low and the payer has no free seconds, or the project reached the daily spending cap set in the console. |
403 | calls_disabled, audio_disabled, video_disabled | The account, project or call type is switched off. |
409 | call_ended | You asked for a token on a call that has ended. Create a new call. |
429 | concurrency_limit, rate_limited | Up 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:
| Value | Where 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: 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.
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
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
- See requirements and the FAQ on the Android video calling SDK page.
- Everything the app can do with the App Key (calls, Live Hosts, live streams, gifts): the Client API (Quick mode).
- Optional, with a server endpoint: verify webhooks and store receipts. See Webhooks and signed receipts and the webhooks reference.
- Read the quickstart, and the REST API reference for the server routes.
- Let your users call verified hosts without running hosts yourself: the Live Hosts API uses the same join code.
- Other platforms: all SDKs, including the web SDK.
