Browse SDKs · Android
SDKsAndroid

Update your profile

Use setSelfInfo() to update the nickname, avatar, or extension data of the current user.

Copy

Set only the fields that must change on UserInfoReq.

UserInfoReq request = new UserInfoReq();
request.setNickname(displayName.trim());
request.setFaceURL(avatarURL);
request.setEx(extra);

OpenIMClient.getInstance().userInfoManager.setSelfInfo(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Profile update succeeded.
        }

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

UserInfoReq supports fields such as nickname, faceURL, ex, and addFriendPermission. Use ex to store extension data for the current user.

A successful callback means the update request completed. onSelfInfoUpdated(UserInfo info) reports changes to the current user's profile.

Updatable fields

FieldDescription
nicknameNew nickname.
faceURLNew avatar URL.
exUser extension string.
addFriendPermissionAdd-friend permission value.

Send only fields that should change. To set global message reception, see Set global message reception.

Receive onSelfInfoUpdated through OnUserListener when the current user's profile changes:

@Override
public void onSelfInfoUpdated(UserInfo info) {
    // Handle the current user's profile change.
}