SDKsAndroid
Create a text message
Use createTextMessage to create a text Message.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
text | String | Yes | The 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
- Local initialization: The method constructs a local
Messageinstance without emitting network calls or SDK events. - Sending the message: Append the returned
Messageto the local chat UI with a sending status, then call Send a message to deliver it to a single user or group.
Was this page helpful?