Documentation Index Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
Field Value Package com.cometchat:chat-uikit-androidKey components CometChatSearch, CometChatMessageList, CometChatMessageComposer, CometChatMessageHeaderPurpose Full-text message search across conversations with result routing and navigation Sample app GitHub Related 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
< com.cometchat.chatuikit.search.CometChatSearch
android:id = "@+id/cometchat_search"
android:layout_width = "match_parent"
android:layout_height = "match_parent" />
2. Handle conversation result clicks
When a user taps a conversation result, navigate to the message view for that conversation.
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)
}
CometChatSearch search = findViewById ( R . id . cometchat_search );
search . setOnConversationClicked ((view, position, conversation) -> {
Intent intent = new Intent ( this , ChatActivity . class );
intent . putExtra ( "conversation" , conversation);
startActivity (intent);
});
File: SearchActivity
3. Handle message result clicks
When a user taps a message result, navigate to the conversation and scroll to that message using setMessageId() on the message list.
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)
}
search . setOnMessageClicked ((view, position, message) -> {
Intent intent = new Intent ( this , ChatActivity . class );
if ( message . getReceiverType (). equals ( CometChatConstants . RECEIVER_TYPE_USER )) {
intent . putExtra ( "uid" , ((User) message . getReceiver ()). getUid ());
} else {
intent . putExtra ( "guid" , ((Group) message . getReceiver ()). getGuid ());
}
intent . putExtra ( "messageId" , message . getId ());
startActivity (intent);
});
File: SearchActivity
4. Scope search to a specific conversation (optional)
Restrict search results to a single user or group conversation.
// 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
search . setUid ( "alice-uid" );
// Or scope to a specific group conversation
search . setGuid ( "group-guid" );
Control which filter chips appear and which is selected by default.
search. setSearchFilters (
listOf (
UIKitConstants.SearchFilter.MESSAGES,
UIKitConstants.SearchFilter.CONVERSATIONS
)
)
search. setInitialSearchFilter (UIKitConstants.SearchFilter.MESSAGES)
search . setSearchFilters (
Arrays . asList (
UIKitConstants . SearchFilter . MESSAGES ,
UIKitConstants . SearchFilter . CONVERSATIONS
)
);
search . setInitialSearchFilter ( UIKitConstants . SearchFilter . MESSAGES );
Feature Matrix
Feature Component / Method File Search interface CometChatSearchSearchActivity Conversation results setOnConversationClickedSearchActivity Message results setOnMessageClickedSearchActivity Scoped search setUid / setGuidSearchActivity Filter chips setSearchFilters / setInitialSearchFilterSearchActivity
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