Skip to main content

Get the Moments list for all friends. Pagination before or after a specified time is supported.

GetMomentOption structure

NameTypeDescriptionVersion
countintRetrieve the specified number of Moments, up to 20 records per request1.8.30
directionJIMConst.PullDirectionRetrieval direction. Use startTime to retrieve older or newer Moments.1.8.30
startTimelongStart time for retrieving Moments. Use with direction; 0 uses the current time.1.8.30
userIdStringRetrieve the Moments list published by a specified user. If empty, retrieves the Moments list for all friends. This parameter is supported only by getMomentList, not getCachedMomentList.1.8.44

API Reference

/**
* get the Moments list
* @param option retrieval options
* @param callback result callback
*/
void getMomentList(GetMomentOption option, JIMConst.IResultListCallback<Moment> callback);

Code Example

GetMomentOption o = new GetMomentOption();
o.setCount(10);
o.setStartTime(0);
o.setDirection(JIMConst.PullDirection.OLDER);
JIM.getInstance().getMomentManager().getMomentList(o, new JIMConst.IResultListCallback<Moment>() {
@Override
public void onSuccess(List<Moment> data, boolean isFinish) {
}

@Override
public void onError(int errorCode) {
}
});

Get Locally Cached Moments

/**
* Get the cached Moments list (cached data may not be the latest version; use it to render the UI immediately for a better user experience).
* @param option retrieval options
* @return cached Moments list
*/
List<Moment> getCachedMomentList(GetMomentOption option);
GetMomentOption o = new GetMomentOption();
o.setCount(10);
o.setStartTime(0);
o.setDirection(JIMConst.PullDirection.OLDER);
List<Moment> momentList = JIM.getInstance().getMomentManager().getCachedMomentList(o);