Browse SDKs · Android
SDKsAndroidEnterprise

Load newer messages

Use getAdvancedHistoryMessageListReverse to load messages after a starting point.

Copy

getAdvancedHistoryMessageListReverse() reads toward newer messages after a specified message. Use it to continue downward from a search result or another located message. It runs in the opposite direction from ordinary history loading and does not receive live messages.

Parameters

ParameterTypeRequiredDescription
conversationIDStringYesConversation whose history is being loaded.
startMsgMessageYesMessage after which loading begins.
countintYesMaximum number of messages to load; the example uses 20.
viewTypeViewTypeYesPass ViewType.History when browsing message history.
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, then append messages to the current list.
        }

        @Override
        public void onError(int code, String error) {
            // Keep the current list and report that this page failed to load.
        }
    },
    conversationID,
    startMessage,
    20,
    ViewType.History
);

Result

The success callback returns AdvancedMessage. messageList contains messages read after the anchor, and isEnd indicates whether the newer end of the available history has been reached. errCode and errMsg carry the business status included in the result object. Continue handling live messages through Receive messages.