MessagesActivity
with the target user’s UID → chat UI loads.
build.gradle
.<uses-permission android:name="android.permission.INTERNET"/>
in AndroidManifest.xml
.CometChatUIKit.login()
before invoking this feature.MessagesActivity
capable of handling one-on-one chats.Component / Class | Responsibility |
---|---|
UserDetailsActivity | Shows user profile UI and Message Privately button. |
MessagesActivity | Chat screen for one-on-one conversation with a User . |
MainActivity | (Optional) entry point for sending initial message programmatically. |
CometChatUIKit.login() | Authenticates the current user session. |
CometChat.sendMessage() | Sends a dummy text message to initialize conversation. |
UserDetailsActivity
to MessagesActivity
with the selected user.
UserDetailsActivity.java
User
JSON extra and configure the chat UI.
MessagesActivity.java
MainActivity.java
Step | Action | Location |
---|---|---|
1 | Tap Message Privately button | UserDetailsActivity.java |
2 | Launch MessagesActivity with user JSON extra | UserDetailsActivity onClick listener |
3 | Deserialize and bind User to UI Kit components | MessagesActivity.onCreate() |
4 | (Optional) Send initial message to surface chat list | MainActivity.sendInitialMessage() |
messagePrivatelyBtn
in activity_user_details.xml
.R.string.app_user
.Condition | Behavior |
---|---|
User never chatted before | The conversation appears after the first message is sent. |
Target user blocked | Composer hidden; consider showing unblock prompt. |
Invalid user data | Guard against null JSON and show error UI or fallback. |
Missing JSON extra | Do not initialize chat; optionally close screen with warning. |
Feature | Component / Method |
---|---|
Launch private chat | Intent from messagePrivatelyBtn |
Initialize chat UI | messageHeader.setUser() , messageList.setUser() |
Create conversation | CometChat.sendMessage() optional |