Browse SDKs · Android
Platform
SDKsAndroid

Update the current user profile

Update the nickname, avatar, or custom extensions for the authenticated user using setSelfInfo().

Copy

Update basic profile attributes for the authenticated user, including nickname, avatar URL, and custom business extension strings. Populate only the fields that require modification.

Code example

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 updated successfully
        }

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

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
requestUserInfoReqYesRequest payload holding fields to update.

Profile attributes

FieldTypeDescription
nicknameStringNew display nickname to set.
faceURLStringNew avatar image URL.
exStringCustom business metadata string formatted according to application specifications.

Friend request permissions and account-wide DND rules are managed independently; see Set friend request permissions and Set global message reception.

Return value

The successful callback indicates that the server persisted the profile updates. The changes synchronize across all devices authenticated with the user account.

State changes after the call

After updating the profile, the SDK dispatches the update via OnUserListener. Locate the cached profile by userID, merge modified properties, and refresh the UI:

@Override
public void onSelfInfoUpdated(UserInfo info) {
    // Current user profile updated; merge local cache and refresh the UI
}