Browse SDKs · Android
SDKsAndroid

Create a rich-text message

Use createAdvancedTextMessage to create a rich-text message with structured entity ranges.

Copy

RichMessage marks a range in the text with offset and length, while type, url, and info carry application-defined entity data.

RichMessage link = new RichMessage();
link.setType("link");
link.setOffset(0);
link.setLength(6);
link.setUrl("https://docs.openim.io");
link.setInfo("{\"title\":\"OpenIM documentation\"}");

Message message = OpenIMClient.getInstance().messageManager.createAdvancedTextMessage(
    "OpenIM docs",
    Collections.singletonList(link)
);

Every entity range must match an actual range in the final text. Validate the ranges, URLs, and info values before sending, and make sure receiving clients use the same type and info protocol. This method only creates a Message; send it through Send a message.