Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide walks you through adding voice and video calling capabilities to your Android application using the CometChat UI Kit.
Add the Calls SDK
Add the CometChat Calls SDK dependency alongside your chosen UI Kit module:
Kotlin (XML Views)
Jetpack Compose
dependencies {
implementation("com.cometchat:chatuikit-kotlin-android:6.0.0-beta2")
implementation("com.cometchat:calls-sdk-android:4.3.3")
}
dependencies {
implementation("com.cometchat:chatuikit-compose-android:6.0.0-beta2")
implementation("com.cometchat:calls-sdk-android:4.3.3")
}
After adding this dependency, the Android UI Kit will automatically detect it and activate the calling features. You will see the CometChatCallButtons component rendered in the MessageHeader component.
Set Up Call Listener
To receive incoming calls globally in your app, add a CallListener before initializing the CometChat UI Kit. We recommend creating a custom Application class:
Kotlin (XML Views)
Jetpack Compose
class BaseApplication : Application() {
companion object {
private val LISTENER_ID = "${BaseApplication::class.java.simpleName}${System.currentTimeMillis()}"
}
override fun onCreate() {
super.onCreate()
CometChat.addCallListener(LISTENER_ID, object : CometChat.CallListener {
override fun onIncomingCallReceived(call: Call) {
// Get the current activity context
val currentActivity = getCurrentActivity() // Implement this method
currentActivity?.let {
val incomingCallView = CometChatIncomingCall(it)
incomingCallView.call = call
incomingCallView.fitsSystemWindows = true
incomingCallView.onError = OnError { exception ->
// Handle errors
}
// Display the component (e.g., as dialog or full-screen overlay)
}
}
override fun onOutgoingCallAccepted(call: Call) {
// Handle accepted outgoing call
}
override fun onOutgoingCallRejected(call: Call) {
// Handle rejected outgoing call
}
override fun onIncomingCallCancelled(call: Call) {
// Handle cancelled incoming call
}
})
}
}
class BaseApplication : Application() {
companion object {
private val LISTENER_ID = "${BaseApplication::class.java.simpleName}${System.currentTimeMillis()}"
}
override fun onCreate() {
super.onCreate()
CometChat.addCallListener(LISTENER_ID, object : CometChat.CallListener {
override fun onIncomingCallReceived(call: Call) {
CometChatCallActivity.launchIncomingCallScreen(this@BaseApplication, call, null)
// Pass null or IncomingCallConfiguration if need to configure CometChatIncomingCall component
}
override fun onOutgoingCallAccepted(call: Call) {
// Handle accepted outgoing call
}
override fun onOutgoingCallRejected(call: Call) {
// Handle rejected outgoing call
}
override fun onIncomingCallCancelled(call: Call) {
// Handle cancelled incoming call
}
})
}
}