AI Agent Component Spec
AI Agent Component Spec
Where It Fits
CometChatOutgoingCall is a call-initiation component. It renders the outgoing call screen and transitions to the ongoing call screen when the receiver accepts. Wire it to CometChatCallEvents to handle call-accepted and call-rejected transitions.
- Kotlin
- Java
CallActivity.kt
Quick Start
Add the component to your layout XML:layout_activity.xml

CometChatUIKit.init(), a user logged in, and the cometchat-chat-uikit-android dependency added.
To add programmatically in an Activity:
- Kotlin
- Java
YourActivity.kt
- Kotlin
- Java
YourFragment.kt
Actions and Events
Callback Methods
setOnEndCallClick
Fires when the end-call button is tapped. Default: cancels the outgoing call via the SDK.
- Kotlin
- Java
YourActivity.kt
What this does: Replaces the default end-call button behavior. When the user taps the end-call button, your custom OnClick lambda executes instead of the built-in call cancellation.
setOnError
Fires on internal errors (network failure, auth issue, SDK exception).
- Kotlin
- Java
YourActivity.kt
What this does: Registers an error callback on theCometChatOutgoingCallinstance. When an error occurs within the component, theonErrormethod is invoked with theCometChatExceptioncontaining error details.
- Verify: After setting an action callback, trigger the corresponding user interaction (tap end-call, cause an error) and confirm your custom logic executes instead of the default behavior.
Global UI Events (CometChatCallEvents)
CometChatCallEvents emits events subscribable from anywhere in the application. Add a listener and remove it when no longer needed.
| Event | Fires when | Payload |
|---|---|---|
ccCallAccepted | The outgoing call is accepted by the receiver | Call |
ccCallRejected | The outgoing call is rejected by the receiver | Call |
- Kotlin
- Java
Add Listener
SDK Events
The component listens to SDK call events internally. No manual attachment needed unless additional side effects are required.| SDK Listener | Internal behavior |
|---|---|
onOutgoingCallAccepted | Transitions to the ongoing call screen |
onOutgoingCallRejected | Finishes the activity or invokes the back-press handler |
Functionality
Small functional customizations for sound and call behavior.| Method | Description | Code |
|---|---|---|
disableSoundForCall | Enables or disables the outgoing call ringtone | .disableSoundForCall(true); |
setCustomSoundForCalls | Sets a custom sound resource for the outgoing call ringtone | .setCustomSoundForCalls(R.raw.custom_ringtone); |
- Verify: After calling
disableSoundForCall(true), initiate an outgoing call and confirm no ringtone plays.
Custom View Slots
Each slot replaces a section of the default UI. All view slots accept aFunction2<Context, Call, View> that receives the current context and Call object and returns a custom View.
| Slot | Method | Replaces |
|---|---|---|
| Title view | setTitleView(Function2<Context, Call, View>) | Name / title text |
| Subtitle view | setSubtitleView(Function2<Context, Call, View>) | Subtitle text (e.g., “Calling…”) |
| Avatar view | setAvatarView(Function2<Context, Call, View>) | Avatar / profile picture area |
| End-call view | setEndCallView(Function2<Context, Call, View>) | End-call button |
setTitleView
Replace the name / title text area.
- Kotlin
- Java
YourActivity.kt
What this does: Registers a callback that receives theExample with sender and receiver names:ContextandCallobject and returns a customViewto replace the default title area on the outgoing call screen.

custom_title_view.xml layout:
custom_title_view.xml
- Kotlin
- Java
YourActivity.kt
What this does: Inflates thecustom_title_viewlayout, retrieves the call receiver’s name and the sender’s UID, and sets the title text to display them separated by" <> ".
setSubtitleView
Replace the subtitle text below the title.
- Kotlin
- Java
YourActivity.kt
What this does: Registers a callback that receives theExample with call-type icon and “Calling…” text:ContextandCallobject and returns a customViewto replace the default subtitle area on the outgoing call screen.

custom_subtitle_view.xml layout:
custom_subtitle_view.xml
- Kotlin
- Java
YourActivity.kt
What this does: Inflates thecustom_subtitle_viewlayout, sets the subtitle text to “Calling…”, and displays a voice call icon if the call type isCALL_TYPE_AUDIO, or a video call icon otherwise.
setAvatarView
Replace the avatar / profile picture area.
- Kotlin
- Java
YourActivity.kt
What this does: Registers a callback that receives theExample with admin badge:ContextandCallobject and returns a customViewto replace the default avatar area on the outgoing call screen.

custom_avatar_view.xml layout:
custom_avatar_view.xml
- Kotlin
- Java
YourActivity.kt
What this does: Inflates thecustom_avatar_viewlayout, retrieves the call receiver’s UID and avatar URL, sets them on theCometChatAvatarwidget, and applies centered layout params.
setEndCallView
Replace the end-call button.
- Kotlin
- Java
YourActivity.kt
What this does: Registers a callback that receives theExample with custom end-call card:ContextandCallobject and returns a customViewto replace the default end-call button on the outgoing call screen.

end_call_button.xml layout:
end_call_button.xml
- Kotlin
- Java
YourActivity.kt
What this does: Inflates the end_call_button layout, attaches a click listener that shows a toast message “End call clicked”, sets a 40dp bottom margin, and returns the custom end-call button view.
- Verify: After setting any custom view slot, confirm the custom view renders in the correct position on the outgoing call screen and that the data binding populates correctly.
Common Patterns
Silent outgoing call
- Kotlin
- Java
Custom ringtone
- Kotlin
- Java
Custom call settings for ongoing call
- Kotlin
- Java
Handle end-call with custom navigation
- Kotlin
- Java
Advanced Methods
setCall
Sets the call object and extracts the receiver User automatically. Use this when you have a Call object from the SDK.
- Kotlin
- Java
setCallinternally extracts the receiver from theCallobject and callssetUserwith it. The component then displays the receiver’s name and avatar.
setUser
Sets the user directly when you don’t have a Call object. The uid, name, and avatar fields are required.
- Kotlin
- Java
setCallSettingsBuilder
Configures the ongoing call settings (audio mode, video settings, etc.) that apply once the call is accepted.
- Kotlin
- Java
setCustomSoundForCalls
Sets a custom ringtone sound that plays while the outgoing call is ringing.
- Kotlin
- Java
disposeObservers
Removes lifecycle observers manually. Normally handled automatically when the view detaches from the window.
- Kotlin
- Java
Internal Access
| Method | Returns | Description |
|---|---|---|
getViewModel() | OutgoingViewModel | The ViewModel managing call state and SDK listeners |
Use this only when the standard API is insufficient. Directly manipulating the ViewModel may conflict with the component’s internal state management.
Style
The component uses XML theme styles. Define a custom style with parentCometChatOutgoingCallStyle in themes.xml, then apply with setStyle().

themes.xml
- Kotlin
- Java
Programmatic Style Properties
In addition to XML theme styles, the component exposes programmatic setters for fine-grained control:| Method | Type | Description |
|---|---|---|
setBackgroundColor | @ColorInt int | Background color of the component |
setTitleTextColor | @ColorInt int | Title text color |
setTitleTextAppearance | @StyleRes int | Title text appearance |
setSubtitleTextColor | @ColorInt int | Subtitle text color |
setSubtitleTextAppearance | @StyleRes int | Subtitle text appearance |
setEndCallIcon | Drawable | Custom end-call button icon |
setEndCallIconTint | @ColorInt int | Tint color for the end-call icon |
setEndCallButtonBackgroundColor | @ColorInt int | Background color for the end-call button |
setAvatarStyle | @StyleRes int | Style for the avatar |
setCornerRadius | @Dimension int | Corner radius of the component |
setStrokeWidth | @Dimension int | Stroke width of the component border |
setStrokeColor | @ColorInt int | Stroke color of the component border |
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Set the call object | Activity/Fragment | setCall(Call) | .setCall(call) |
| Set the user directly | Activity/Fragment | setUser(User) | .setUser(user) |
| Override end-call behavior | Activity/Fragment | setOnEndCallClick(OnClick) | See setOnEndCallClick code above |
| Handle errors | Activity/Fragment | setOnError(OnError) | See setOnError code above |
| Disable outgoing call sound | Activity/Fragment | disableSoundForCall(boolean) | .disableSoundForCall(true); |
| Set custom outgoing call sound | Activity/Fragment | setCustomSoundForCalls(@RawRes int) | .setCustomSoundForCalls(R.raw.custom_ringtone); |
| Configure ongoing call settings | Activity/Fragment | setCallSettingsBuilder(CallSettingsBuilder) | .setCallSettingsBuilder(builder) |
| Title view | Activity/Fragment | setTitleView(Function2) | See setTitleView code above |
| Subtitle view | Activity/Fragment | setSubtitleView(Function2) | See setSubtitleView code above |
| Avatar view | Activity/Fragment | setAvatarView(Function2) | See setAvatarView code above |
| End-call button view | Activity/Fragment | setEndCallView(Function2) | See setEndCallView code above |
| Avatar style (corner radius, background) | themes.xml | CometChatOutgoingCallStyle with cometchatOutgoingCallAvatarStyle | <item name="cometchatAvatarStrokeRadius">8dp</item> |
| Apply a custom style | Activity/Fragment | setStyle(@StyleRes int) | cometChatOutgoingCall.setStyle(R.style.CustomOutgoingCall); |
| Title text color | Activity/Fragment | setTitleTextColor(@ColorInt int) | .setTitleTextColor(Color.WHITE); |
| Subtitle text color | Activity/Fragment | setSubtitleTextColor(@ColorInt int) | .setSubtitleTextColor(Color.GRAY); |
| End-call icon | Activity/Fragment | setEndCallIcon(Drawable) | .setEndCallIcon(drawable); |
| End-call icon tint | Activity/Fragment | setEndCallIconTint(@ColorInt int) | .setEndCallIconTint(Color.WHITE); |
| End-call button background | Activity/Fragment | setEndCallButtonBackgroundColor(@ColorInt int) | .setEndCallButtonBackgroundColor(Color.RED); |
| Background color | Activity/Fragment | setBackgroundColor(@ColorInt int) | .setBackgroundColor(Color.BLACK); |
| Corner radius | Activity/Fragment | setCornerRadius(@Dimension int) | .setCornerRadius(16); |
| Stroke width | Activity/Fragment | setStrokeWidth(@Dimension int) | .setStrokeWidth(2); |
| Stroke color | Activity/Fragment | setStrokeColor(@ColorInt int) | .setStrokeColor(Color.GRAY); |
Accessibility
The component renders a full-screen outgoing call view. The end-call button responds to tap gestures. The avatar image includes the user name as content description. The title and subtitle text views are readable by screen readers. For custom views provided viasetTitleView, setSubtitleView, setAvatarView, or setEndCallView, ensure you set android:contentDescription on visual-only elements so TalkBack can announce them. The default views handle this automatically.