Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Load newer messages

Use getAdvancedHistoryMessageListReverse to load messages after a starting point.

Copy

Retrieve historical messages forward in time (towards newer messages) starting from a specific anchor message. This is commonly used when jumping to a search result, navigating from a quoted reply, or restoring deep-linked message contexts. This method queries stored messages and is not used for real-time message streaming.

Code example

String conversationID = "si_user_a_user_b";
int count = 20;

OpenIMClient.getInstance().messageManager.getAdvancedHistoryMessageListReverse(
    new OnBase<AdvancedMessage>() {
        @Override
        public void onSuccess(AdvancedMessage result) {
            List<Message> messages = result.getMessageList();
            boolean reachedLatest = result.isEnd();
            // Deduplicate by clientMsgID and append messages to the bottom of the active timeline
        }

        @Override
        public void onError(int code, String error) {
            // Failed to load newer messages
        }
    },
    conversationID,
    startMessage,
    count,
    ViewType.History
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<AdvancedMessage>YesCallback handler for the asynchronous request.
conversationIDStringYesGlobally unique ID of the target conversation.
startMsgMessageYesAnchor starting message from which forward loading begins.
countintYesMaximum number of messages to retrieve in this batch.
viewTypeViewTypeYesView mode enum. Pass ViewType.History for regular history loads.

Return value

Upon success, onSuccess returns an AdvancedMessage object. messageList contains messages chronologically after the anchor message, and isEnd indicates whether the newest stored message boundary has been reached.

State changes after the call

  1. Snapshot retrieval: This is a read-only query that loads point-in-time message records without emitting new-message events.
  2. Timeline update: Append deduplicated messages to the bottom of the chat list using clientMsgID. Real-time incoming messages continue to be received via Receive messages.