Skip to main content
{
  "component": "CometChatIncomingCall",
  "package": "com.cometchat.chatuikit.calls.incomingcall",
  "xmlElement": "<com.cometchat.chatuikit.calls.incomingcall.CometChatIncomingCall />",
  "description": "Full-screen incoming call banner with caller avatar, name, call type indicator, and accept/reject buttons.",
  "primaryOutput": {
    "method": "setOnAcceptClick",
    "type": "OnClick"
  },
  "methods": {
    "data": {
      "setCall": {
        "type": "Call",
        "note": "Required. Sets the Call object so accept/reject actions work correctly."
      }
    },
    "callbacks": {
      "setOnAcceptClick": "OnClick",
      "setOnRejectClick": "OnClick",
      "setOnError": "OnError"
    },
    "functionality": {
      "disableSoundForCalls": { "type": "boolean", "default": "false" },
      "setCustomSoundForCalls": { "type": "@RawRes int", "default": "SDK default ringtone" }
    },
    "viewSlots": {
      "setItemView": "View — entire incoming call card",
      "setLeadingView": "View — avatar / left section",
      "setTitleView": "View — caller name / title text",
      "setSubtitleView": "View — subtitle text below name",
      "setTrailingView": "View — right section"
    },
    "advanced": {
      "setCall": "Call — sets the call object (required)",
      "setCallSettingsBuilder": "CometChatCalls.CallSettingsBuilder — custom call settings",
      "getViewModel": "IncomingCallViewModel — internal ViewModel access",
      "getBinding": "CometchatIncomingCallComponentBinding — root ViewBinding"
    },
    "style": {
      "setStyle": {
        "type": "@StyleRes int",
        "parent": "CometChatIncomingCallStyle"
      }
    }
  },
  "events": [
    {
      "name": "CometChatCallEvents.ccCallAccepted",
      "payload": "Call",
      "description": "A call was accepted"
    },
    {
      "name": "CometChatCallEvents.ccCallRejected",
      "payload": "Call",
      "description": "A call was rejected"
    }
  ],
  "sdkListeners": [
    "onIncomingCallReceived",
    "onIncomingCallCancelled"
  ]
}

Where It Fits

CometChatIncomingCall is a call-handling component. It renders when the logged-in user receives an incoming voice or video call, displaying the caller’s information and providing accept/reject controls. Wire it to CometChatOngoingCallActivity after the user accepts the call.
CallHandlerActivity.kt
class CallHandlerActivity : AppCompatActivity() {

    private lateinit var incomingCall: CometChatIncomingCall

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_call_handler)

        incomingCall = findViewById(R.id.incoming_call)

        // Set the Call object received from CometChat SDK
        incomingCall.setCall(call)

        incomingCall.setOnAcceptClick {
            // Navigate to ongoing call screen
        }

        incomingCall.setOnRejectClick {
            // Dismiss the incoming call screen
            finish()
        }
    }
}

Quick Start

Add the component to your layout XML:
layout_activity.xml
<com.cometchat.chatuikit.calls.incomingcall.CometChatIncomingCall
        android:id="@+id/incoming_call"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the cometchat-chat-uikit-android dependency added. In your Activity, get a reference and set the Call object:
YourActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.layout_activity)

    val incomingCall = findViewById<CometChatIncomingCall>(R.id.incoming_call)
    incomingCall.setCall(call) // Required — pass the Call object from the SDK
}
To add programmatically in an Activity:
YourActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    val incomingCall = CometChatIncomingCall(this)
    incomingCall.setCall(call)
    setContentView(incomingCall)
}
Or in a Fragment:
YourFragment.kt
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
    val incomingCall = CometChatIncomingCall(requireContext())
    incomingCall.setCall(call)
    return incomingCall
}

Actions and Events

Callback Methods

setOnAcceptClick

Fires when the user taps the accept button. Override this to replace the default call-accept behavior.
YourActivity.kt
cometchatIncomingCall.setOnAcceptClick {
    // Custom accept logic
}
What this does: Replaces the default accept-button behavior. When the user taps the accept button, your custom OnClick lambda executes instead of the built-in call-accept logic.

setOnRejectClick

Fires when the user taps the reject button. Override this to replace the default call-reject behavior.
YourActivity.kt
cometchatIncomingCall.setOnRejectClick {
    // Custom reject logic
}
What this does: Replaces the default reject-button behavior. When the user taps the reject button, your custom OnClick lambda executes instead of the built-in call-decline logic.

setOnError

Fires on internal errors (network failure, call failure, SDK exception).
YourActivity.kt
cometchatIncomingCall.setOnError { cometchatException ->
    // Handle error
}
What this does: Registers an error listener. If the component encounters an error, your callback receives the CometChatException so you can handle it with custom logic.
  • Verify: After setting an action callback, trigger the corresponding user interaction (tap accept, tap reject) 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.
EventFires whenPayload
ccCallAcceptedA call is acceptedCall
ccCallRejectedA call is rejectedCall
ccCallEndedA call is endedCall
ccOutgoingCallAn outgoing call is initiatedCall
Add Listener
CometChatCallEvents.addListener("LISTENER_TAG", object : CometChatCallEvents() {
    override fun ccCallAccepted(call: Call?) {
        super.ccCallAccepted(call)
    }

    override fun ccCallRejected(call: Call?) {
        super.ccCallRejected(call)
    }

    override fun ccCallEnded(call: Call?) {
        super.ccCallEnded(call)
    }
})
Remove Listener
CometChatCallEvents.removeListener("LISTENER_TAG")

SDK Events

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.
SDK ListenerInternal behavior
onIncomingCallReceivedTriggers the incoming call screen display
onIncomingCallCancelledDismisses the incoming call screen
Automatic: call state changes update the component in real time.

Functionality

Small functional customizations such as toggling call sounds and setting custom ringtones.
MethodDescriptionCode
disableSoundForCallsDisables the ringtone for incoming calls.disableSoundForCalls(true);
setCustomSoundForCallsSets a custom ringtone from res/raw.setCustomSoundForCalls(R.raw.custom_ringtone);
  • Verify: After calling disableSoundForCalls(true), confirm no ringtone plays on incoming calls. After calling setCustomSoundForCalls, confirm the custom sound plays.

Custom View Slots

Each slot replaces a section of the default UI. IncomingCall view slots accept plain View objects (not ViewHolderListener).
SlotMethodReplaces
Item viewsetItemView(View)Entire incoming call card
Leading viewsetLeadingView(View)Avatar / left section
Title viewsetTitleView(View)Caller name / title text
Subtitle viewsetSubtitleView(View)Subtitle text below name
Trailing viewsetTrailingView(View)Right section

setItemView

Replace the entire incoming call card with a custom view.
YourActivity.kt
cometchatIncomingCall.setItemView(view)
What this does: Replaces the entire default incoming call card with your custom View. The custom view is responsible for rendering all caller information and call controls.

setLeadingView

Replace the avatar / left section.
YourActivity.kt
cometchatIncomingCall.setLeadingView(view)
What this does: Replaces the default leading (left) area of the incoming call screen with your custom View.
Example:
leading_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/cometchat_45dp"
    android:layout_height="@dimen/cometchat_45dp"
    android:orientation="vertical">

    <com.cometchat.chatuikit.shared.views.avatar.CometChatAvatar
        android:id="@+id/avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>
YourActivity.kt
val leadingView: View = LayoutInflater.from(this).inflate(R.layout.leading_view, null)
val avatar = leadingView.findViewById<CometChatAvatar>(R.id.avatar)
val callUser = call.callInitiator as User
avatar.setAvatar(callUser.name, callUser.avatar)
leadingView.layoutParams = LinearLayout.LayoutParams(
    Utils.convertDpToPx(this, 45),
    Utils.convertDpToPx(this, 45)
)
cometchatIncomingCall.setTrailingView(null)
cometchatIncomingCall.setLeadingView(leadingView)

setTitleView

Replace the caller name / title text.
YourActivity.kt
cometchatIncomingCall.setTitleView(view)
What this does: Replaces the default title area of the incoming call screen with your custom View.
Example:
custom_title_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/user_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="teacher"
        android:textAppearance="?attr/cometchatTextAppearanceHeading4Medium"
        android:textColor="?attr/cometchatTextColorPrimary" />

    <View
        android:id="@+id/role"
        android:layout_width="50dp"
        android:layout_height="15dp"
        android:layout_marginStart="@dimen/cometchat_16dp"
        android:background="@drawable/important" />
</LinearLayout>
YourActivity.kt
val titleView: View = LayoutInflater.from(this).inflate(R.layout.custom_title_view, null)
val title = titleView.findViewById<TextView>(R.id.title)
title.text = "George Allen"
titleView.layoutParams = LinearLayout.LayoutParams(
    ViewGroup.LayoutParams.WRAP_CONTENT,
    ViewGroup.LayoutParams.WRAP_CONTENT
)
cometchatIncomingCall.setTitleView(titleView)

setSubtitleView

Replace the subtitle text below the caller’s name.
YourActivity.kt
cometchatIncomingCall.setSubtitleView(view)
What this does: Replaces the default subtitle area of the incoming call screen with your custom View. Use this to show additional information below the caller’s name.

setTrailingView

Replace the right section of the incoming call card.
YourActivity.kt
cometchatIncomingCall.setTrailingView(view)
What this does: Replaces the default trailing (right) area of the incoming call screen with your custom View.
Example:
trailing_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/cometchat_45dp"
    android:layout_height="@dimen/cometchat_45dp"
    android:orientation="vertical">

    <com.cometchat.chatuikit.shared.views.avatar.CometChatAvatar
        android:id="@+id/avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>
YourActivity.kt
val trailingView: View = LayoutInflater.from(this).inflate(R.layout.trailing_view, null)
val avatar = trailingView.findViewById<CometChatAvatar>(R.id.avatar)
val callUser = call.callInitiator as User
if (callUser.tags.contains("pro_user")) {
    avatar.setAvatar(ResourcesCompat.getDrawable(resources, R.drawable.pro_user, null)!!)
}
avatar.setAvatar(callUser.name, callUser.avatar)
trailingView.layoutParams = LinearLayout.LayoutParams(
    Utils.convertDpToPx(this, 45),
    Utils.convertDpToPx(this, 45)
)
cometchatIncomingCall.setTrailingView(trailingView)
  • Verify: After setting any custom view slot, confirm the custom view renders in the correct position on the incoming call screen and displays the expected caller information.

Common Patterns

Silent incoming call

cometchatIncomingCall.disableSoundForCalls(true)

Custom ringtone

cometchatIncomingCall.setCustomSoundForCalls(R.raw.my_ringtone)

Custom call settings

val callSettingsBuilder = CometChatCalls.CallSettingsBuilder(this, true)
    .setDefaultAudioMode("SPEAKER")
cometchatIncomingCall.setCallSettingsBuilder(callSettingsBuilder)

Override accept to add logging

cometchatIncomingCall.setOnAcceptClick {
    Log.d("IncomingCall", "Call accepted by user")
    // Proceed with default accept via ViewModel
    cometchatIncomingCall.viewModel.acceptCall(call)
}

Advanced Methods

setCall

Sets the Call object for the incoming call screen. Required for accept/reject actions to work correctly. The component extracts the caller’s name, avatar, and call type from this object.
cometchatIncomingCall.setCall(call)

setCallSettingsBuilder

Provides a custom CallSettingsBuilder to configure call settings (audio mode, video resolution, etc.) used when the call is accepted.
val builder = CometChatCalls.CallSettingsBuilder(this, true)
cometchatIncomingCall.setCallSettingsBuilder(builder)

Internal Access

These methods provide direct access to internal components for advanced use cases.
MethodReturnsDescription
getViewModel()IncomingCallViewModelThe ViewModel managing call state and actions
getBinding()CometchatIncomingCallComponentBindingThe ViewBinding for the component’s root layout
Use these only when the standard API is insufficient. Directly manipulating the ViewModel or binding may conflict with the component’s internal state management.

Style

The component uses XML theme styles. Define a custom style with parent CometChatIncomingCallStyle in themes.xml, then apply with setStyle().
themes.xml
<style name="CustomAvatarStyle" parent="CometChatAvatarStyle">
    <item name="cometchatAvatarStrokeRadius">8dp</item>
    <item name="cometchatAvatarBackgroundColor">#FBAA75</item>
</style>

<style name="CustomIncomingCallStyle" parent="CometChatIncomingCallStyle">
    <item name="cometchatIncomingCallBackgroundColor">#AA9EE8</item>
    <item name="cometchatIncomingCallIconTint">?attr/cometchatPrimaryColor</item>
    <item name="cometchatIncomingCallRejectButtonBackgroundColor">?attr/cometchatColorWhite</item>
    <item name="cometchatIncomingCallAcceptButtonBackgroundColor">?attr/cometchatPrimaryColor</item>
    <item name="cometchatIncomingCallRejectButtonTextColor">?attr/cometchatErrorColor</item>
    <item name="cometchatIncomingCallAcceptButtonTextColor">?attr/cometchatColorWhite</item>
    <item name="cometchatIncomingCallRejectButtonTextAppearance">?attr/cometchatTextAppearanceButtonMedium</item>
    <item name="cometchatIncomingCallAcceptButtonTextAppearance">?attr/cometchatTextAppearanceButtonMedium</item>
    <item name="cometchatIncomingCallAvatarStyle">@style/CustomAvatarStyle</item>
</style>
cometchatIncomingCall.setStyle(R.style.CustomIncomingCallStyle)
To know more such attributes, visit the attributes file.

Programmatic Style Properties

In addition to XML theme styles, the component exposes programmatic setters for fine-grained control:
MethodTypeDescription
setBackgroundColor@ColorInt intBackground color of the component
setTitleTextColor@ColorInt intText color for the caller name
setTitleTextAppearance@StyleRes intText appearance for the caller name
setSubtitleTextColor@ColorInt intText color for the call type subtitle
setSubtitleTextAppearance@StyleRes intText appearance for the call type subtitle
setIconTint@ColorInt intTint color for the call type icon
setVoiceCallIconDrawableCustom icon for voice calls
setVideoCallIconDrawableCustom icon for video calls
setAcceptCallButtonBackgroundColor@ColorInt intBackground color for the accept button
setRejectCallButtonBackgroundColor@ColorInt intBackground color for the reject button
setAcceptButtonTextColor@ColorInt intText color for the accept button
setRejectButtonTextColor@ColorInt intText color for the reject button
setAcceptButtonTextAppearance@StyleRes intText appearance for the accept button
setRejectButtonTextAppearance@StyleRes intText appearance for the reject button
setCornerRadius@Dimension intCorner radius of the component card
setStrokeWidth@Dimension intStroke width of the component border
setStrokeColor@ColorInt intStroke color of the component border
setAvatarStyle@StyleRes intStyle for the caller avatar
  • Verify: The incoming call screen displays with a purple background (#AA9EE8), custom button colors, and avatars with rounded corners (8dp radius) and an orange background (#FBAA75).

Customization Matrix

What to changeWhereProperty/APIExample
Background colorthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallBackgroundColor<item name="cometchatIncomingCallBackgroundColor">#AA9EE8</item>
Icon tintthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallIconTint<item name="cometchatIncomingCallIconTint">?attr/cometchatPrimaryColor</item>
Reject button backgroundthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallRejectButtonBackgroundColor<item name="cometchatIncomingCallRejectButtonBackgroundColor">?attr/cometchatColorWhite</item>
Accept button backgroundthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallAcceptButtonBackgroundColor<item name="cometchatIncomingCallAcceptButtonBackgroundColor">?attr/cometchatPrimaryColor</item>
Reject button text colorthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallRejectButtonTextColor<item name="cometchatIncomingCallRejectButtonTextColor">?attr/cometchatErrorColor</item>
Accept button text colorthemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallAcceptButtonTextColor<item name="cometchatIncomingCallAcceptButtonTextColor">?attr/cometchatColorWhite</item>
Reject button text appearancethemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallRejectButtonTextAppearance<item name="cometchatIncomingCallRejectButtonTextAppearance">?attr/cometchatTextAppearanceButtonMedium</item>
Accept button text appearancethemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallAcceptButtonTextAppearance<item name="cometchatIncomingCallAcceptButtonTextAppearance">?attr/cometchatTextAppearanceButtonMedium</item>
Avatar stylethemes.xmlCometChatIncomingCallStyle with cometchatIncomingCallAvatarStyle<item name="cometchatIncomingCallAvatarStyle">@style/CustomAvatarStyle</item>
Apply a custom styleActivity/FragmentsetStyle(int styleRes)cometchatIncomingCall.setStyle(R.style.CustomIncomingCallStyle);
Call objectActivity/FragmentsetCall(Call).setCall(call)
Custom call soundActivity/FragmentsetCustomSoundForCalls(@RawRes int).setCustomSoundForCalls(R.raw.custom_ringtone);
Disable call soundActivity/FragmentdisableSoundForCalls(boolean).disableSoundForCalls(true)
Call settingsActivity/FragmentsetCallSettingsBuilder(CallSettingsBuilder).setCallSettingsBuilder(builder)
Accept button actionActivity/FragmentsetOnAcceptClick(OnClick)See setOnAcceptClick code above
Reject button actionActivity/FragmentsetOnRejectClick(OnClick)See setOnRejectClick code above
Error handlerActivity/FragmentsetOnError(OnError)See setOnError code above
Entire call card viewActivity/FragmentsetItemView(View)cometchatIncomingCall.setItemView(view);
Leading view (avatar area)Activity/FragmentsetLeadingView(View)See setLeadingView code above
Title view (caller name)Activity/FragmentsetTitleView(View)See setTitleView code above
Subtitle viewActivity/FragmentsetSubtitleView(View)cometchatIncomingCall.setSubtitleView(view);
Trailing viewActivity/FragmentsetTrailingView(View)See setTrailingView code above

Accessibility

The component renders a full-screen incoming call card with interactive accept and reject buttons. The caller’s avatar includes the caller name as content description. The accept and reject buttons are labeled for screen readers. For custom views provided via setLeadingView, setTitleView, setSubtitleView, or setTrailingView, ensure you set android:contentDescription on visual-only elements so TalkBack can announce them. The default views handle this automatically. The call type icon (voice/video) is visual-only by default. If screen reader descriptions are needed, provide them via a custom view with appropriate contentDescription attributes.

Next Steps