Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Modify a message

Modify supported message content and handle modification events received by other clients.

Copy

Edit and update the content of an already-sent message online. Typically, you clone the original Message object, modify editable fields (such as text content in textElem), and submit the updated object while retaining all original identifiers (clientMsgID, serverMsgID).

Code example

// Clone or copy original message and update text content
Message modifiedMessage = originalMessage;
modifiedMessage.getTextElem().setContent("This is the updated message content.");

OpenIMClient.getInstance().messageManager.modifyMessage(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Message modified successfully
        }

        @Override
        public void onError(int code, String error) {
            // Failed to modify message
        }
    },
    modifiedMessage
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback handler for the asynchronous request.
messageMessageYesThe updated Message object. Must retain original identifiers including clientMsgID, serverMsgID, and conversation bindings.

Return value

Upon success, data in onSuccess returns a confirmation message.

Handling message modification events

After a message is modified, other online clients in the conversation receive the updated Message through OnAdvanceMsgListener.onMessageModified:

@Override
public void onMessageModified(Message message) {
    // message contains updated content; refresh UI by message.getClientMsgID()
}

Upon receiving onMessageModified, match the message by clientMsgID to refresh the text bubble in-place and display an "edited" status indicator.

State changes after the call

  1. Callback confirmation: The onSuccess callback indicates that the modification was saved on the server. Update the local UI model with the new content.
  2. Asynchronous event delivery: Peer clients receive onMessageModified with the complete updated Message. Merge in-place using clientMsgID.
  3. Re-query calibration: If message content falls out of sync, reload via Load older messages.

For complete listener registration and lifecycle management, see Receive messages.