Browse SDKs · Android
Platform
SDKsAndroid

Create a mention message

Use createTextAtMessage to create a text message that mentions group members.

Copy

Construct a text message with @ mentions targeting specific group members, with optional quoting of a previous message. When delivered, recipient clients display high-priority mention notifications and badges in the conversation list.

Code example

String text = "@Alex Please review the latest proposal";
List<String> userIDs = Collections.singletonList("user_alex");

AtUserInfo atUserInfo = new AtUserInfo();
atUserInfo.setAtUserID("user_alex");
atUserInfo.setGroupNickname("Alex");
List<AtUserInfo> atUserInfos = Collections.singletonList(atUserInfo);

Message quoteMessage = null; // Pass an existing Message object to quote-reply, or null

Message message = OpenIMClient.getInstance().messageManager.createTextAtMessage(
    text,
    userIDs,
    atUserInfos,
    quoteMessage
);

Parameters

ParameterTypeRequiredDescription
textStringYesThe complete text of the message, including @ mention labels.
userIDsList<String>YesList of user IDs of the mentioned group members (deduplicated).
atUserInfosList<AtUserInfo>YesList of user details corresponding to userIDs, containing display names and identifiers.
quoteMessageMessageNoOptional reference to a previous message to quote-reply. Pass null if not quoting.

Return value

Returns the newly initialized Message object ready for transmission.

State changes after the call

  1. Local initialization: Initializes the local Message structure without sending data to the server.
  2. Sending to the group: Mention messages are typically used in group conversations. Call Send a message passing the target group ID (recvGid).