Browse SDKs · Android
Platform
SDKsAndroid

Create a text message

Use createTextMessage to create a text Message.

Copy

Construct a standard plain text message object. This method initializes a local Message instance and populates its textElem field; it does not trigger a network request or transmit the message to the server.

Code example

String text = "Hello, this is a plain text message.";

Message message = OpenIMClient.getInstance().messageManager.createTextMessage(text);

Parameters

ParameterTypeRequiredDescription
textStringYesThe text content of the message. Validate text length on the client before calling.

Return value

Returns the newly initialized Message object with contentType set to MessageType.TEXT.

State changes after the call

  1. Local initialization: The method constructs a local Message instance without emitting network calls or SDK events.
  2. Sending the message: Append the returned Message to the local chat UI with a sending status, then call Send a message to deliver it to a single user or group.