Browse SDKs · Android
SDKsAndroid

Check friendship

Use checkFriend() to check whether specified users are friends of the current user.

Copy
OpenIMClient.getInstance().friendshipManager.checkFriend(
    new OnBase<List<FriendshipInfo>>() {
        @Override
        public void onSuccess(List<FriendshipInfo> relations) {
            // Use relations to update the friendship display.
        }

        @Override
        public void onError(int code, String error) {
            // Handle the error.
        }
    },
    Arrays.asList("user_a", "user_b")
);

The callback returns List<FriendshipInfo>. Each item's userID is the target user ID. Call friendshipInfo.getResult() to get the relationship result; 1 means the user is a friend of the current user and is not in the blacklist.

See Get specified friend profiles when nickname, avatar, or friend remark data is required.