Documentation Index Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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.
Kotlin (XML Views)
Jetpack Compose
< 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)
CometChatIncomingCall (
call = call
)
Quick Start
Kotlin (XML Views)
Jetpack Compose
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)
}
@Composable
fun IncomingCallScreen () {
CometChatIncomingCall (
call = 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.
Kotlin (XML Views)
Jetpack Compose
incomingCall. setOnAcceptClick {
// Custom accept logic
}
CometChatIncomingCall (
call = call,
onAcceptClick = { /* custom accept logic */ }
)
onRejectClick
Fires when the user taps the reject button.
Kotlin (XML Views)
Jetpack Compose
incomingCall. setOnRejectClick {
// Custom reject logic
finish ()
}
CometChatIncomingCall (
call = call,
onRejectClick = { /* custom reject logic */ }
)
onError
Fires on internal errors (network failure, call failure, SDK exception).
Kotlin (XML Views)
Jetpack Compose
incomingCall. setOnError { exception ->
Log. e ( "IncomingCall" , "Error: ${ exception.message } " )
}
CometChatIncomingCall (
call = call,
onError = { exception ->
Log. e ( "IncomingCall" , "Error: ${ exception.message } " )
}
)
Global UI Events (CometChatCallEvents)
Event Fires when Payload ccCallAcceptedA call is accepted CallccCallRejectedA call is rejected Call
SDK Events (Real-Time, Automatic)
SDK Listener Internal behavior onIncomingCallReceivedTriggers the incoming call screen display onIncomingCallCancelledDismisses the incoming call screen
Functionality
Method (Kotlin XML) Compose Parameter Description 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.
Kotlin (XML Views)
Jetpack Compose
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)
CometChatIncomingCall (
call = call,
leadingView = { c ->
val caller = c.callInitiator as ? User
CometChatAvatar (
imageUrl = caller?.avatar,
name = caller?.name
)
}
)
Title View
Replace the caller name / title text.
Kotlin (XML Views)
Jetpack Compose
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)
CometChatIncomingCall (
call = call,
titleView = { c ->
val caller = c.callInitiator as ? User
Text (
text = caller?.name ?: "" ,
style = CometChatTheme.typography.heading4Medium
)
}
)
Trailing View
Replace the right section of the incoming call card.
Kotlin (XML Views)
Jetpack Compose
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)
CometChatIncomingCall (
call = call,
trailingView = { c ->
val caller = c.callInitiator as ? User
CometChatAvatar (
imageUrl = caller?.avatar,
name = caller?.name,
modifier = Modifier. size ( 45 .dp)
)
}
)
Item View
Replace the entire incoming call card.
Kotlin (XML Views)
Jetpack Compose
incomingCall. setItemView (customView)
CometChatIncomingCall (
call = call,
itemView = { c ->
// Fully custom incoming call card
}
)
Style
Kotlin (XML Views)
Jetpack Compose
Define a custom style in 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)
CometChatIncomingCall (
call = call,
style = CometChatIncomingCallStyle. default (). copy (
backgroundColor = Color ( 0xFFAA9EE8 ),
acceptButtonBackgroundColor = CometChatTheme.colors.primary,
rejectButtonBackgroundColor = Color.White,
rejectButtonTextColor = CometChatTheme.colors.error,
acceptButtonTextColor = Color.White
)
)
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