Skip to main content
CometChatCallButtons renders voice and video call buttons and initiates calls for the bound User or Group. Place it in a CometChatMessageHeader or anywhere a call action is needed.

Where It Fits

CometChatCallButtons is a utility component. Wire it into a CometChatMessageHeader or place it standalone wherever a call action is needed.
activity_chat.xml
<com.cometchat.uikit.kotlin.presentation.callbuttons.CometChatCallButtons
    android:id="@+id/call_buttons"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
val callButtons = findViewById<CometChatCallButtons>(R.id.call_buttons)
callButtons.setUser(user)

Quick Start

Add to your layout XML:
<com.cometchat.uikit.kotlin.presentation.callbuttons.CometChatCallButtons
    android:id="@+id/call_buttons"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
Set a User or Group — required before calls can be initiated:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.your_layout)

    val callButtons = findViewById<CometChatCallButtons>(R.id.call_buttons)
    callButtons.setUser(user)
    // or callButtons.setGroup(group)
}
Or programmatically:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val callButtons = CometChatCallButtons(this)
    callButtons.setUser(user)
    setContentView(callButtons)
}
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.
You must call setUser(User) or setGroup(Group) before the buttons can initiate a call. Without a target, button clicks have no effect.

Actions and Events

Callback Methods

onVoiceCallClick

Fires when the voice call button is tapped. Replaces the default behavior of initiating an audio call.
callButtons.setOnVoiceCallClick { user, group ->
    // Custom voice call logic
}

onVideoCallClick

Fires when the video call button is tapped. Replaces the default behavior of initiating a video call.
callButtons.setOnVideoCallClick { user, group ->
    // Custom video call logic
}

onError

Fires on internal errors (network failure, auth issue, SDK exception).
callButtons.setOnError { exception ->
    Log.e("CallButtons", "Error: ${exception.message}")
}

Global UI Events (CometChatCallEvents)

EventFires whenPayload
ccOutgoingCallAn outgoing call is initiatedCall
ccCallAcceptedA call is accepted by the recipientCall
ccCallRejectedA call is rejected by the recipientCall
ccCallEndedA call is endedCall

Functionality

Method (Kotlin XML)Compose ParameterDescription
setUser(user)user = userSet the user to call (required for 1-on-1)
setGroup(group)group = groupSet the group to call (required for group calls)
setOnVoiceCallClick { }onVoiceCallClick = { }Override voice call button behavior
setOnVideoCallClick { }onVideoCallClick = { }Override video call button behavior
setOnError { }onError = { }Error callback
setVoiceCallButtonVisibility(View.GONE)hideVoiceCallButton = trueToggle voice call button
setVideoCallButtonVisibility(View.GONE)hideVideoCallButton = trueToggle video call button

Style

Define a custom style in themes.xml:
themes.xml
<style name="CustomCallButtonsStyle" parent="CometChatCallButtonsStyle">
    <item name="cometchatCallButtonsVoiceCallIconTint">#4CAF50</item>
    <item name="cometchatCallButtonsVideoCallIconTint">#2196F3</item>
    <item name="cometchatCallButtonsVoiceCallBackgroundColor">#E8F5E9</item>
    <item name="cometchatCallButtonsVideoCallBackgroundColor">#E3F2FD</item>
</style>
callButtons.setStyle(R.style.CustomCallButtonsStyle)
See Component Styling for the full reference.

ViewModel

val viewModel = ViewModelProvider(this)
    .get(CometChatCallButtonsViewModel::class.java)
callButtons.setViewModel(viewModel)
See ViewModel & Data for state observation and custom repositories.

Next Steps

Call Logs

View call history

Incoming Call

Incoming call notification with accept/reject

Outgoing Call

Outgoing call screen with end-call button

Message Header

Display user/group info in the toolbar