Skip to main content
Enable users to start one-on-one or group chats by integrating CometChat’s New Chat screen (CometChatUsers + CometChatGroups), providing a seamless flow from your conversation list to a specific chat.

Overview

Users can tap the ”+” icon in the conversation toolbar or bottom navigation to:
  • Browse and search CometChat users.
  • Browse and search CometChat groups.
  • Select a user or group to launch a chat.
This streamlines contact/group discovery and boosts engagement by reducing friction in starting conversations.

Prerequisites

  • Android project with CometChat UIKit Android v5 (com.cometchat:chatuikit-kotlin or com.cometchat:chatuikit-jetpack) added in build.gradle.
  • CometChat credentials (App ID, Auth Key, Region) initialized.
  • Navigation configured: ConversationActivityNewChatActivityMessagesActivity.
  • Internet and network permissions granted in AndroidManifest.xml.

Components

Integration Steps

1. Add Entry Point to New Chat

Show a ”+” icon that launches NewChatActivity.
ConversationActivity.kt

2. Implement New Chat Screen

Build a tabbed interface with Users and Groups lists.
NewChatActivity.kt

3. Handle User or Group Selection

Launch MessagesActivity when an item is tapped.
NewChatActivity.kt

4. Open the Messages Screen

Read intent extras and configure chat UI.
MessagesActivity.kt

Implementation Flow

  1. User taps the ”+” icon → NewChatActivity launches (or Compose navigation).
  2. Tabs switch between Users and Groups.
  3. Selection triggers MessagesActivity with JSON payload.
  4. Chat UI initializes with the passed user/group.
  5. Real-time messaging begins via the UI Kit.

Customization Options

  • Styling: Apply cometchatTheme attributes to TabLayout and list items.
  • Filtering: Customize UsersRequestBuilder / GroupsRequestBuilder (e.g., hideBlockedUsers(true)).
  • Navigation: Replace default MessagesActivity with a custom screen.
  • Layout Tweaks: Use android:fitsSystemWindows="true" to avoid overlap.

Filtering & Edge Cases

  • Empty States: Built-in empty views in CometChatUsers and CometChatGroups.
  • Protected Groups: Prompt for password or disable selection.
  • Network Errors: Observe error callbacks and show Snackbar messages.

Error Handling

  • Default loading and error states are handled by the UI Kit.
  • Attach observers on CometChatUsers / CometChatGroups to handle failures.
  • Use Toast or Snackbar for custom error feedback.

Summary / Feature Matrix

Next Steps & Further Reading

Android Sample App (Kotlin)

Explore this feature in the CometChat SampleApp: GitHub → SampleApp