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.
Field Value Packages com.cometchat:chatuikit-kotlin-android · com.cometchat:chatuikit-compose-androidKey components CometChatSearch, CometChatMessageList, CometChatMessageComposer, CometChatMessageHeaderPurpose Full-text message search across conversations with result routing and navigation Sample app GitHub Related Search Component , All Guides
Search Messages lets users locate specific messages across conversations and groups using keyword search, then navigate directly to the result.
Before starting, complete the Getting Started guide.
Components
Component / Class Role CometChatSearchMain search interface with filter chips and result lists CometChatMessageListDisplays messages in the selected conversation CometChatMessageComposerMessage input for the selected conversation CometChatMessageHeaderHeader bar showing conversation context
Integration Steps
1. Add CometChatSearch to your layout
Kotlin (XML Views)
Jetpack Compose
< com.cometchat.uikit.kotlin.presentation.search.ui.CometChatSearch
android:id = "@+id/cometchat_search"
android:layout_width = "match_parent"
android:layout_height = "match_parent" />
import com.cometchat.uikit.compose.presentation.search.ui.CometChatSearch
@Composable
fun SearchScreen (navController: NavController ) {
CometChatSearch (
modifier = Modifier. fillMaxSize (),
onConversationClick = { conversation ->
navController. navigate ( "messages/ ${ Gson (). toJson (conversation) } " )
},
onMessageClick = { message ->
if (message.receiverType == CometChatConstants.RECEIVER_TYPE_USER) {
navController. navigate ( "messages/user/ ${ (message.receiver as User).uid } / ${ message.id } " )
} else {
navController. navigate ( "messages/group/ ${ (message.receiver as Group).guid } / ${ message.id } " )
}
}
)
}
2. Handle conversation result clicks
When a user taps a conversation result, navigate to the message view for that conversation.
Kotlin (XML Views)
Jetpack Compose
val search: CometChatSearch = findViewById (R.id.cometchat_search)
search. setOnConversationClicked { view, position, conversation ->
val intent = Intent ( this , ChatActivity:: class .java)
intent. putExtra ( "conversation" , conversation)
startActivity (intent)
}
// Handled inline via onConversationClick lambda in the CometChatSearch composable above
3. Handle message result clicks
When a user taps a message result, navigate to the conversation and scroll to that message.
Kotlin (XML Views)
Jetpack Compose
search. setOnMessageClicked { view, position, message ->
val intent = Intent ( this , ChatActivity:: class .java)
if (message.receiverType == CometChatConstants.RECEIVER_TYPE_USER) {
intent. putExtra ( "uid" , (message.receiver as User).uid)
} else {
intent. putExtra ( "guid" , (message.receiver as Group).guid)
}
intent. putExtra ( "messageId" , message.id)
startActivity (intent)
}
// Handled inline via onMessageClick lambda in the CometChatSearch composable above
4. Scope search to a specific conversation (optional)
Restrict search results to a single user or group conversation.
Kotlin (XML Views)
Jetpack Compose
// Scope to a specific user conversation
search. setUid ( "alice-uid" )
// Or scope to a specific group conversation
search. setGuid ( "group-guid" )
// Scope to a specific user conversation
CometChatSearch (
uid = "alice-uid" ,
modifier = Modifier. fillMaxSize (),
onConversationClick = { /* handle click */ },
onMessageClick = { /* handle click */ }
)
// Or scope to a specific group conversation
CometChatSearch (
guid = "group-guid" ,
modifier = Modifier. fillMaxSize (),
onConversationClick = { /* handle click */ },
onMessageClick = { /* handle click */ }
)
Control which filter chips appear.
Kotlin (XML Views)
Jetpack Compose
search. setSearchFilters (
listOf (
UIKitConstants.SearchFilter.MESSAGES,
UIKitConstants.SearchFilter.CONVERSATIONS
)
)
search. setInitialSearchFilter (UIKitConstants.SearchFilter.MESSAGES)
import com.cometchat.uikit.core.constants.SearchFilter
CometChatSearch (
searchFilters = listOf (
SearchFilter.UNREAD,
SearchFilter.GROUPS,
SearchFilter.PHOTOS,
SearchFilter.VIDEOS
),
modifier = Modifier. fillMaxSize (),
onConversationClick = { /* handle click */ },
onMessageClick = { /* handle click */ }
)
Feature Matrix
Feature Kotlin (XML Views) Jetpack Compose Search interface CometChatSearch XML elementCometChatSearch() composableConversation results setOnConversationClickedonConversationClick lambdaMessage results setOnMessageClickedonMessageClick lambdaScoped search setUid() / setGuid()uid / guid parametersFilter chips setSearchFilters()searchFilters parameterCustom views setEmptyView(), setErrorView()emptyView, errorView composable slots
Next Steps
Search The search component reference
Message List Display messages in a conversation
All Guides Browse all feature and formatter guides
Sample App Full working sample application on GitHub