Get the friend list by page
Use getFriendListPage() to retrieve the current user friend list by page.
OpenIMClient.getInstance().friendshipManager.getFriendListPage(
new OnBase<List<UserInfo>>() {
@Override
public void onSuccess(List<UserInfo> friends) {
// Use friends to update the friend list.
}
@Override
public void onError(int code, String error) {
// Handle the error.
}
},
0,
40,
true
);The arguments after the callback are offset, count, and filterBlack. offset starts at 0, count is the page size, and filterBlack removes blocked users when true. The callback returns the current page as List<UserInfo>; call getFriendInfo() on each item for relationship details. Increase offset by the requested item count when loading another page; a page smaller than count normally marks the end.
Friend profile fields
UserInfo.getFriendInfo() returns FriendInfo for a friend list item. Common fields are:
| Field | Description |
|---|---|
userID | Friend user ID. |
nickname | Account nickname of the friend. |
faceURL | Account avatar URL of the friend. |
remark | Friend remark set by the current account. |
ex | Friendship extension string. |
addSource | Source that created the friendship. |
operatorUserID | User ID that created or updated the relationship. |
createTime | Friendship creation time. |
nickname and faceURL are account data, while remark and ex belong to the friendship. UpdateFriendsReq can submit isPinned, but the current Android FriendInfo model has no corresponding read field.
Receive friend added, changed, and deleted callbacks through OnFriendshipListener:
@Override
public void onFriendAdded(FriendInfo friend) {
// Handle the added friend.
}
@Override
public void onFriendInfoChanged(FriendInfo friend) {
// Handle the changed friend.
}
@Override
public void onFriendDeleted(FriendInfo friend) {
// Handle the deleted friend.
}Was this page helpful?