Skip to main content
CometChatIncomingCall renders when the logged-in user receives an incoming voice or video call, displaying the caller’s information and providing accept/reject controls.

Where It Fits

CometChatIncomingCall is a call-handling component. It renders the incoming call screen and transitions to the ongoing call screen when the user accepts. Wire it to CometChatOngoingCallActivity after the user accepts the call.
activity_call.xml
<com.cometchat.uikit.kotlin.presentation.incomingcall.CometChatIncomingCall
    android:id="@+id/incoming_call"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
val incomingCall = findViewById<CometChatIncomingCall>(R.id.incoming_call)
incomingCall.setCall(call)

Quick Start

Add to your layout XML:
<com.cometchat.uikit.kotlin.presentation.incomingcall.CometChatIncomingCall
    android:id="@+id/incoming_call"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
Set the Call object — this is required:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.layout_activity)

    val incomingCall = findViewById<CometChatIncomingCall>(R.id.incoming_call)
    incomingCall.setCall(call)
}
Prerequisites: CometChat SDK initialized with CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.

Actions and Events

Callback Methods

onAcceptClick

Fires when the user taps the accept button.
incomingCall.setOnAcceptClick {
    // Custom accept logic
}

onRejectClick

Fires when the user taps the reject button.
incomingCall.setOnRejectClick {
    // Custom reject logic
    finish()
}

onError

Fires on internal errors (network failure, call failure, SDK exception).
incomingCall.setOnError { exception ->
    Log.e("IncomingCall", "Error: ${exception.message}")
}

Global UI Events (CometChatCallEvents)

EventFires whenPayload
ccCallAcceptedA call is acceptedCall
ccCallRejectedA call is rejectedCall

SDK Events (Real-Time, Automatic)

SDK ListenerInternal behavior
onIncomingCallReceivedTriggers the incoming call screen display
onIncomingCallCancelledDismisses the incoming call screen

Functionality

Method (Kotlin XML)Compose ParameterDescription
setCall(call)call = callSet the Call object (required)
setOnAcceptClick { }onAcceptClick = { }Override accept button behavior
setOnRejectClick { }onRejectClick = { }Override reject button behavior
setOnError { }onError = { }Error callback
setDisableSoundForCalls(true)disableSoundForCalls = trueDisable incoming call ringtone
setCustomSoundForCalls(R.raw.tone)customSoundForCalls = R.raw.toneCustom ringtone

Custom View Slots

Leading View

Replace the avatar / left section.
val leadingView = 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)
)
incomingCall.setLeadingView(leadingView)

Title View

Replace the caller name / title text.
val titleView = LayoutInflater.from(this).inflate(R.layout.custom_title_view, null)
val title = titleView.findViewById<TextView>(R.id.title)
title.text = "George Allen"
incomingCall.setTitleView(titleView)

Trailing View

Replace the right section of the incoming call card.
val trailingView = LayoutInflater.from(this).inflate(R.layout.trailing_view, null)
val avatar = trailingView.findViewById<CometChatAvatar>(R.id.avatar)
val callUser = call.callInitiator as User
avatar.setAvatar(callUser.name, callUser.avatar)
trailingView.layoutParams = LinearLayout.LayoutParams(
    Utils.convertDpToPx(this, 45),
    Utils.convertDpToPx(this, 45)
)
incomingCall.setTrailingView(trailingView)

Item View

Replace the entire incoming call card.
incomingCall.setItemView(customView)

Style

Define a custom style in themes.xml:
themes.xml
<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>
</style>
incomingCall.setStyle(R.style.CustomIncomingCallStyle)
See Component Styling for the full reference.

Next Steps

Outgoing Call

Outgoing call screen with end-call button

Call Buttons

Voice and video call buttons

Call Logs

View call history

Conversations

Browse recent conversations