Skip to main content
Implement threaded replies in your Android chat app using CometChat’s UI Kit, enabling users to reply to specific messages in a focused sub-conversation.

Overview

Threaded replies allow users to respond directly to a specific message in one-on-one or group chats, improving context and readability:
  • Organizes related replies into a dedicated thread view.
  • Mirrors functionality in Slack, Discord, and WhatsApp.
  • Maintains clarity in active conversations.
Users tap a message → open thread screen → view parent message + replies → compose within thread.

Prerequisites

  • Android project in Android Studio.
  • CometChat Android UI Kit v5 (com.cometchat:chatuikit-kotlin or com.cometchat:chatuikit-jetpack) added to your build.gradle.
  • Valid CometChat App ID, Auth Key, and Region initialized.
  • <uses-permission android:name="android.permission.INTERNET"/> in AndroidManifest.xml.
  • Logged-in user via CometChatUIKit.login().
  • Existing MessagesActivity using CometChatMessageList.

Components

Integration Steps

Step 1: Add Thread Layout

Create res/layout/activity_thread_message.xml:
activity_thread_message.xml

Step 2: Set up ThreadMessageActivity

Initialize UI & handle blocked-user flows:

Step 3: Create ThreadMessageViewModel

Store parent message and expose via StateFlow:

Step 4: Hook Thread Entry from Message List

In your MessagesActivity, capture thread icon taps:

Implementation Flow

  1. User taps thread icon on a message.
  2. Intent launches ThreadMessageActivity with raw message JSON (or Compose navigation).
  3. ViewModel stores parent message and exposes via StateFlow.
  4. Header & MessageList render parent + replies.
  5. Composer sends new replies under the parent message.
  6. Live updates flow automatically via UI Kit.

Customization Options

  • Styling: Override theme attributes or call setter methods on views.
  • Header Height: threadHeader.setMaxHeight(...).
  • Hide Reactions: threadHeader.setReactionVisibility(View.GONE).

Filtering & Edge Cases

  • Group Membership: Verify membership before enabling composer.
  • Empty Thread: Show placeholder if no replies.
  • Blocked Users: Composer hidden; use unblock layout.

Blocked-User Handling

Group vs. User-Level Differences

Summary / Feature Matrix

Next Steps & Further Reading

Android Sample App (Kotlin)

Explore this feature in the CometChat SampleApp: GitHub → SampleApp