Skip to main content

Where It Fits

CometChatCallButtons is a utility component. It renders voice and video call buttons and initiates calls for the bound User or Group. Wire it into a CometChatMessageHeader or place it anywhere a call action is needed.
ChatActivity.kt

Quick Start

Add the component to your layout XML:
layout_activity.xml
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the cometchat-chat-uikit-android dependency added. To add programmatically in an Activity:
YourActivity.kt
Or in a Fragment:
YourFragment.kt
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

setOnVoiceCallClick

Fires when the voice call button is tapped. Replaces the default behavior of initiating an audio call.
YourActivity.kt
What this does: Replaces the default voice call initiation. When a user taps the voice call button, your custom lambda executes instead of the built-in call flow. The OnClick interface provides void onClick(User user, Group group).

setOnVideoCallClick

Fires when the video call button is tapped. Replaces the default behavior of initiating a video call.
YourActivity.kt
  • Verify: After setting a callback, tap the corresponding button and confirm your custom logic executes instead of the default call initiation.

Global UI Events (CometChatCallEvents)

CometChatCallEvents emits events subscribable from anywhere in the application. Add a listener and remove it when no longer needed.
Add Listener
Remove Listener

SDK Events

The component uses an internal CallButtonsViewModel that observes call initiation and direct call events. No manual SDK listener attachment is needed — the component handles call lifecycle internally.

Functionality

Small functional customizations such as toggling visibility of UI elements and configuring button spacing.
  • Verify: After calling a visibility method, confirm the corresponding UI element is shown or hidden.

Custom View Slots

CometChatCallButtons exposes direct access to its two internal CometChatButton instances. Use these to customize icons, text, colors, and other properties on each button individually.
  • Verify: After accessing a button via getVoiceCallButton() or getVideoCallButton(), confirm your customizations render correctly on the corresponding button.

Common Patterns

Video-only buttons

Voice-only buttons

Custom button text

Icon-only buttons

Advanced Methods

setUser / setGroup

Binds the component to a specific user or group. Required before calls can be initiated.

setOutgoingCallConfiguration

Configures the outgoing call screen that appears after a call is initiated.

setCallSettingsBuilder

Provides a callback to customize call settings per call. The callback receives the User, Group, and a Boolean indicating whether the call is audio (true) or video (false), and returns a CometChatCalls.CallSettingsBuilder.

getVoiceCallButton / getVideoCallButton

Returns the internal CometChatButton instances for direct customization.

disposeObservers

Removes lifecycle observers manually. Normally handled automatically when the view detaches from the window.

Style

The component uses XML theme styles. Define a custom style with parent CometChatCallButtonsStyle in themes.xml, then apply with setStyle().
themes.xml

Programmatic Style Properties

In addition to XML theme styles, the component exposes programmatic setters for fine-grained control:

Customization Matrix

Next Steps

Call Logs

View call history

Message Header

Display user/group info in the toolbar

Conversations

Browse recent conversations

Incoming Call

Incoming call notification with accept/reject