Skip to main content

Quickstart

This quickstart shows how to use RealtimeKit's core SDKs to add live video and audio to your Android applications.

To get started quickly, you can use our sample code. You can clone and run a sample application from the Android Core samples, available in both Kotlin and Java.

Objective

You'll learn how to:

Before Getting Started

Make sure you've read the Getting Started with RealtimeKit topic and completed the following steps:

Step 1: Install the SDK

dependencies {
// (other dependencies)
implementation 'com.cloudflare.realtimekit:core:+'
}
Note

If your app targets lower versions of Android (Android API <= 24), please enable core desugaring in your app's build.gradle file as follows.

android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}

dependencies {
// other dependencies
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
}

Step 2: Initialize the SDK

The RealtimeKitClient class is the main entry of the SDK. You can obtain an instance of it using the RealtimeKitMeetingBuilder helper as shown below.

val rtkClient = RealtimeKitMeetingBuilder.build(activity)

Step 3: Configure a RealtimeKit meeting

Configure the following properties in the RtkMeetingInfo class. You must pass a valid participant authToken obtained from the Add Participant API.

NameDescription
authTokenAfter you've created the meeting, add each participant to the meeting using the Add Participant API The API response contains the authToken.
enableAudioSet whether to join the meeting with your Mic ON (true) or OFF (false).
enableVideoSet whether to join the meeting with your Camera ON (true) or OFF (false).
val meetingInfo =
RtkMeetingInfo(
authToken = AUTH_TOKEN,
enableAudio = true,
enableVideo = true,
)

Step 4: Initialize the RealtimeKit meeting

To initialize the meeting, call the init() method on the rtkClient object with the meetingInfo argument. This establishes a connection with the RealtimeKit meeting server.

rtkClient.init(
meetingInfo,
onInitCompleted = {
},
onInitFailed = {
}
)

Step 5: Go live with your RealtimeKit meeting!

Now, you have established the connection with the RealtimeKit meeting server successfully. Next step is to join the room.

Join the room

To join the meeting room, call joinRoom() method on the rtkClient instance as shown below.

rtkClient.joinRoom(
onSuccess = {
},
onFailed = {
}
)

Leave the room

Once the meeting is over, you can leave the meeting room.

To leave the meeting room, call leaveRoom() method on the rtkClient as shown below.

rtkClient.leaveRoom(
onSuccess = {
},
onFailed = {
}
)