CometChatCallButtons provides users with the ability to make voice and video calls. It renders call buttons that, when clicked, initiate a call to the specified user or group.
When to use this
- You need to add voice and video call buttons to a chat screen or user profile.
- You want to trigger outgoing calls to a specific
UserorGroupobject. - You need to customize which call buttons are visible (voice only, video only, or both).
- You want to override the default call-initiation behavior with custom logic.
- You need to configure call settings such as audio/video preferences using
CometChatCalls.CallSettingsBuilder.
Prerequisites
- CometChat SDK initialized with
CometChatUIKit.init()and a user logged in. - The
cometchat-chat-uikit-androiddependency added to your project. - A valid
UserorGroupobject to pass to the component. - A layout XML file or Activity/Fragment where you will place the component.
Quick start
- Open your layout XML file (e.g.,
activity_main.xml). - Add the
CometChatCallButtonsXML element:
activity_main.xml
What this does: Adds the CometChatCallButtons component to your layout with wrap-content sizing. It renders voice and video call buttons.
- In your Activity or Fragment, get a reference to the component and set a
UserorGroupobject:
- Java
- Kotlin
What this does: Retrieves theCometChatCallButtonsinstance from the layout using view binding, then sets either aUserorGroupobject. The component requires one of these to know who to call.
- Build and run your app.
- Verify that the voice and video call buttons appear in your layout.

Core concepts
CometChatCallButtons: The main component class that renders voice and video call buttons. It must be bound to aUserorGroupobject usingsetUser()orsetGroup().- Actions: Callbacks such as
setOnVoiceCallClick,setOnVideoCallClick, andsetOnErrorthat let you override default call-initiation behavior. - Filters: The
CometChatCallButtonscomponent does not have any exposed filters. - Events: Global events emitted by the component (
ccCallAccepted,ccCallRejected) that you can listen to usingCometChatCallEvents. - Style: XML theme styles (parent
CometChatCallButtonsStyle) applied viasetStyle()to customize icon tints, backgrounds, padding, stroke, and corner radius. - Configurations: Use
OutgoingCallConfigurationto customize the outgoing call screen that appears after a call is initiated.
Implementation
Actions
What you’re changing: How the component responds when the user taps a call button or when an error occurs.- Where: Activity or Fragment where you hold a reference to
CometChatCallButtons(e.g.,cometchatCallButtons). - Applies to:
CometChatCallButtons. - Default behavior: Tapping the voice call button initiates a voice call; tapping the video call button initiates a video call. Errors are handled internally.
- Override: Call the corresponding setter method to replace the default behavior with your own logic.
setOnVoiceCallClick
Overrides the default voice call initiation behavior. If you set this, tapping the voice call button executes your custom logic instead of placing a call.
- Java
- Kotlin
What this does: Replaces the default voice call behavior. When the user taps the voice call button, your customOnClicklambda executes with theUserandGroupobjects instead of the built-in call initiation.
setOnVideoCallClick
Overrides the default video call initiation behavior. If you set this, tapping the video call button executes your custom logic instead of placing a call.
- Java
- Kotlin
What this does: Replaces the default video call behavior. When the user taps the video call button, your customOnClicklambda executes with theUserandGroupobjects instead of the built-in call initiation.
setOnError
Overrides the default error handling. If you set this, errors encountered by the component are passed to your custom handler.
- Java
- Kotlin
What this does: Replaces the default error handling. When the component encounters an error (e.g., a failed call initiation), your customOnErrorcallback receives theCometChatException.
- Verify: After setting any action override, tap the corresponding button and confirm your custom logic executes instead of the default behavior.
Events
What you’re changing: How you listen for call-related events emitted by the component.- Where: Activity or Fragment where you want to respond to call events.
- Applies to:
CometChatCallButtons(events are global viaCometChatCallEvents). - Default behavior: The component emits
ccCallAcceptedandccCallRejectedevents when the outgoing call is accepted or rejected. - Override: Add a
CometChatCallEventslistener with a unique ID to receive these events.
| Event | Description |
|---|---|
ccCallAccepted | Triggers when the outgoing call is accepted. |
ccCallRejected | Triggers when the outgoing call is rejected. |
Add CometChatCallEvents
- Java
- Kotlin
What this does: Registers aCometChatCallEventslistener with the tag"UNIQUE_ID". When an outgoing call is accepted,ccCallAcceptedfires with theCallobject. When an outgoing call is rejected,ccCallRejectedfires with theCallobject.
Remove CometChatCallEvents
- Java
- Kotlin
What this does: Removes theCometChatCallEventslistener identified by the tag string. Use the same tag you passed toaddListenerto unsubscribe.
- Verify: After adding the listener, initiate a call and confirm that
ccCallAcceptedorccCallRejectedfires when the recipient responds.
Style
What you’re changing: The visual appearance of the call buttons (icon tints, backgrounds, padding, stroke, corner radius).- Where:
themes.xmlfor the style definition, Activity or Fragment for applying the style. - Applies to:
CometChatCallButtons. - Default behavior: The component uses the default
CometChatCallButtonsStyletheme. - Override: Define a custom style with parent
CometChatCallButtonsStyleinthemes.xml, then apply it withsetStyle(). - Code:

themes.xml
What this does: Defines a custom style named CustomCallButtonStyle that sets purple icon tints, light purple backgrounds, 8dp padding, 1dp gray strokes, and 8dp corner radius for both voice and video call buttons.
- Java
- Kotlin
What this does: Applies theTo know more such attributes, visit the attributes file.CustomCallButtonStyletheme to theCometChatCallButtonsinstance, overriding the default visual appearance.
- Verify: After applying the style, confirm that the call buttons display with the custom icon tints, backgrounds, padding, strokes, and corner radius defined in your style.
Functionality
What you’re changing: Functional properties such as which user or group receives the call, button visibility, call settings, and outgoing call configuration.- Where: Activity or Fragment where you hold a reference to
CometChatCallButtons. - Applies to:
CometChatCallButtons. - Default behavior: Both voice and video call buttons are visible. No call settings builder or outgoing call configuration is set.
- Override: Call the corresponding setter method on the
CometChatCallButtonsinstance.
| Property | Description | Code |
|---|---|---|
setUser | Sets the User object to the call button. | .setUser(User user) |
setGroup | Sets the Group object to the call button. | .setGroup(group) |
setVideoCallButtonVisibility | Hides or shows the video call button. | .setVideoCallButtonVisibility(View.GONE) |
setVoiceCallButtonVisibility | Hides or shows the voice call button. | .setVoiceCallButtonVisibility(View.GONE) |
setCallSettingsBuilder | Sets the call settings builder callback function. This callback configures the call settings based on the user, group, and call type (audio/video). | .setCallSettingsBuilder(Function3<User, Group, Boolean, CometChatCalls.CallSettingsBuilder> callSettingsBuilder) |
setOutgoingCallConfiguration | Sets the configurations for the outgoing call component. | .setOutgoingCallConfiguration(new OutgoingCallConfiguration) |
What this does: These functional properties control which entity receives the call, which buttons are visible, how call settings are configured, and how the outgoing call screen behaves.
- Verify: After setting a property, confirm the expected behavior. If you hide the video call button with
setVideoCallButtonVisibility(View.GONE), only the voice call button is visible. If you set aUserobject, tapping a call button initiates a call to that user.
Configurations
What you’re changing: Properties of the outgoing call screen that appears after a call is initiated fromCometChatCallButtons.
- Where: Activity or Fragment where you hold a reference to
CometChatCallButtons. - Applies to:
CometChatCallButtons(configures the childOutgoingCallcomponent). - Default behavior: The outgoing call screen uses default settings.
- Override: Create an
OutgoingCallConfigurationinstance, configure it, and pass it tosetOutgoingCallConfiguration(). - Code:
- Java
- Kotlin
What this does: Creates anAll exposed properties ofOutgoingCallConfigurationinstance and applies it to theCometChatCallButtonscomponent. This lets you customize the outgoing call screen properties.
OutgoingCallConfiguration can be found under Outgoing Call. Properties marked with the 🛑 symbol are not accessible within the Configuration Object.
- Verify: After setting the outgoing call configuration, initiate a call and confirm the outgoing call screen reflects your configuration changes.
Customization matrix
| What you want to change | Where | Property/API | Example |
|---|---|---|---|
| Video call icon tint | themes.xml | cometchatCallButtonsVideoCallIconTint in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallIconTint">#6852D6</item> |
| Voice call icon tint | themes.xml | cometchatCallButtonsVoiceCallIconTint in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallIconTint">#6852D6</item> |
| Margin between buttons | themes.xml | cometchatCallButtonsMarginBetween in CometChatCallButtonsStyle | <item name="cometchatCallButtonsMarginBetween">16dp</item> |
| Video call button padding | themes.xml | cometchatCallButtonsVideoCallButtonPadding in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallButtonPadding">8dp</item> |
| Voice call button padding | themes.xml | cometchatCallButtonsVoiceCallButtonPadding in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallButtonPadding">8dp</item> |
| Video call background color | themes.xml | cometchatCallButtonsVideoCallBackgroundColor in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallBackgroundColor">#EDEAFA</item> |
| Voice call background color | themes.xml | cometchatCallButtonsVoiceCallBackgroundColor in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallBackgroundColor">#EDEAFA</item> |
| Video call stroke width | themes.xml | cometchatCallButtonsVideoCallStrokeWidth in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallStrokeWidth">1dp</item> |
| Voice call stroke width | themes.xml | cometchatCallButtonsVoiceCallStrokeWidth in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallStrokeWidth">1dp</item> |
| Video call stroke color | themes.xml | cometchatCallButtonsVideoCallStrokeColor in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallStrokeColor">#E8E8E8</item> |
| Voice call stroke color | themes.xml | cometchatCallButtonsVoiceCallStrokeColor in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallStrokeColor">#E8E8E8</item> |
| Video call corner radius | themes.xml | cometchatCallButtonsVideoCallCornerRadius in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVideoCallCornerRadius">8dp</item> |
| Voice call corner radius | themes.xml | cometchatCallButtonsVoiceCallCornerRadius in CometChatCallButtonsStyle | <item name="cometchatCallButtonsVoiceCallCornerRadius">8dp</item> |
| Apply a custom style | Activity/Fragment | setStyle(int styleRes) | cometChatCallButtons.setStyle(R.style.CustomCallButtonStyle); |
| Set user for call | Activity/Fragment | setUser(User user) | .setUser(userObject) |
| Set group for call | Activity/Fragment | setGroup(Group group) | .setGroup(groupObject) |
| Hide video call button | Activity/Fragment | setVideoCallButtonVisibility(int) | .setVideoCallButtonVisibility(View.GONE) |
| Hide voice call button | Activity/Fragment | setVoiceCallButtonVisibility(int) | .setVoiceCallButtonVisibility(View.GONE) |
| Configure call settings | Activity/Fragment | setCallSettingsBuilder(Function3<User, Group, Boolean, CometChatCalls.CallSettingsBuilder>) | .setCallSettingsBuilder(callSettingsBuilder) |
| Configure outgoing call screen | Activity/Fragment | setOutgoingCallConfiguration(OutgoingCallConfiguration) | .setOutgoingCallConfiguration(new OutgoingCallConfiguration()) |
| Override voice call tap | Activity/Fragment | setOnVoiceCallClick(CometChatCallButtons.OnClick) | See setOnVoiceCallClick code above |
| Override video call tap | Activity/Fragment | setOnVideoCallClick(CometChatCallButtons.OnClick) | See setOnVideoCallClick code above |
| Override error handling | Activity/Fragment | setOnError(OnError) | See setOnError code above |
Common pitfalls & fixes
| Pitfall | Fix |
|---|---|
| Component does not render | Ensure CometChatUIKit.init() is called and awaited before using any UI Kit component. If init() has not completed, the component will not load. |
| Call buttons appear but nothing happens on tap | Verify that you have set a User or Group object using setUser() or setGroup(). The component requires one of these to know who to call. |
| Both call buttons visible when only one is needed | Use setVideoCallButtonVisibility(View.GONE) to hide the video call button, or setVoiceCallButtonVisibility(View.GONE) to hide the voice call button. |
| Custom style not applied | Verify the style parent is CometChatCallButtonsStyle and that you call setStyle(R.style.YourStyle) on the component instance. |
setOnVoiceCallClick or setOnVideoCallClick not firing | Ensure you set the action override on the correct CometChatCallButtons instance. If you have multiple instances, each must be configured separately. |
Event listener not receiving ccCallAccepted or ccCallRejected | Ensure you call CometChatCallEvents.addListener with a unique ID string. If you use the same ID as another listener, the previous one is replaced. |
| Outgoing call configuration not taking effect | Ensure you call setOutgoingCallConfiguration() before the call is initiated. If called after the call starts, the configuration may not apply. |
FAQ
Q: Do I need to set both aUser and a Group on CometChatCallButtons?
A: No. Set either a User object with setUser() or a Group object with setGroup(). The component uses whichever is set to determine the call recipient.
Q: How do I show only the voice call button?
A: Call setVideoCallButtonVisibility(View.GONE) on the CometChatCallButtons instance. This hides the video call button and leaves only the voice call button visible.
Q: Can I customize the outgoing call screen that appears after tapping a call button?
A: Yes. Create an OutgoingCallConfiguration instance, configure its properties, and pass it to setOutgoingCallConfiguration(). See the Outgoing Call page for all available properties.
Q: Does CometChatCallButtons support filters?
A: No. The CometChatCallButtons component does not have any exposed filters.
Q: How do I configure call settings like enabling/disabling audio or video?
A: Use setCallSettingsBuilder() to provide a Function3<User, Group, Boolean, CometChatCalls.CallSettingsBuilder> callback that returns a configured CometChatCalls.CallSettingsBuilder based on the user, group, and call type.