Browse SDKs · Android
Platform
SDKsAndroid

Get user profiles

Batch query public user profile cards by a list of user IDs using getUsersInfo().

Copy

Batch query public basic profiles for application users by their user IDs. This is suitable for contact search, stranger profile cards, and user candidate presentations.

Query public profiles

Pass a list of target user IDs to retrieve public profile snapshots in batches. Filter empty strings and duplicate IDs before calling, and keep batch sizes reasonable.

Code example

List<String> userIDs = Arrays.asList("user_a", "user_b");

OpenIMClient.getInstance().userInfoManager.getUsersInfo(
    new OnBase<List<PublicUserInfo>>() {
        @Override
        public void onSuccess(List<PublicUserInfo> users) {
            // Render user profiles with users
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    },
    userIDs
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<List<PublicUserInfo>>YesCallback delivering the asynchronous operation result.
userIDsList<String>YesList of target user IDs to query. Remove duplicate or empty entries before calling.

Return value

The successful callback returns a List<PublicUserInfo> containing the matched public user records:

FieldDescription
userIDUnique global user ID.
nicknamePublic display nickname.
faceURLPublic avatar URL.
exCustom public extension string.
createTimeAccount registration Unix timestamp.

Cache and merge returned public profiles using userID as the unique key. To modify the authenticated user's own profile and extension data, see Update the current user profile.

Search and add friends

When your application obtains candidate userID values, query and display their public profile cards first. After user confirmation, initiate a friend request using Send a friend application.

This method performs exact queries by userID. Fuzzy searching by nickname or phone number requires dedicated backend business API support.

Select profile models by context

A single userID resolves to different profile models depending on context:

ContextModel class
User search, candidate lists, stranger cardsPublicUserInfo
Friend lists, contact screens, friend remarksFriendInfo
Group member lists, in-group nicknames, group rolesGroupMembersInfo

For friend profiles, see Get friend profiles. For group member profiles, see Get the group member list.

Next steps