Browse SDKs · Android
SDKsAndroid

Get the current user profile

Use getSelfLocalUserInfo() to retrieve the local profile for the current user.

Copy
OpenIMClient.getInstance().userInfoManager.getSelfLocalUserInfo(
    new OnBase<LocalUser>() {
        @Override
        public void onSuccess(LocalUser user) {
            currentUserStore.set(user);
        }

        @Override
        public void onError(int code, String error) {
            recordSelfProfileFailure(code, error);
        }
    }
);

After initialization and login, call this method to retrieve the current account's local profile. Success returns LocalUser with fields such as userID, nickname, faceURL, ex, attachedInfo, globalRecvMsgOpt, and addFriendPermission.

Returned fields

FieldDescription
userIDSigned-in user ID.
nicknameCurrent account nickname.
faceURLCurrent account avatar URL.
exCurrent account extension string.
attachedInfoSDK-attached data; parse only an application-defined format.
globalRecvMsgOptGlobal message reception: 0 receive, 1 do not receive, 2 receive without notification.
addFriendPermissionAdd-friend permission value defined by the server contract.

The query does not trigger a profile callback. Clear the previous account snapshot when logging out or switching accounts so that the previous user's data is not rendered for the new account.

getSelfUserInfo() is deprecated and is not the recommended API.