Browse SDKs · Android
SDKsAndroid

User overview

Learn about current-user profiles, public user profiles, account settings, and online status in the Android SDK.

Copy

OpenIM Android SDK identifies each user by userID. User APIs retrieve and update the current account profile, retrieve public user profiles, and subscribe to user online status.

Friends, friend requests, and blacklists are relationship capabilities between users. See Relationship overview for their types, APIs, and state updates.

User objects

Android SDK returns different user objects for different scenarios:

TypeUse caseMain APIs
LocalUserThe signed-in user's local profile, settings page, avatar, nickname, and account-level settingsgetSelfLocalUserInfo(), setSelfInfo()
PublicUserInfoApplication user lookup and public profile cardsgetUsersInfo()
UsersOnlineStatusUser online status and connected platformssubscribeUsersOnlineStatus(), getSubscribeOnlineUsersStatus(), unsubscribeOnlineUsersStatus()

LocalUser represents the signed-in user, while PublicUserInfo represents a public user profile returned by a query. Group member profiles, in-group nicknames, and member management belong to group capabilities.

Feature entry points

RequirementRecommended page
Retrieve public profiles by userID for profile cardsGet specified user profiles
Read or update the current user's nickname, avatar, and extension dataGet the current user profile, Update the current user profile
Configure account-level message reception and notification behaviorSet global message reception
Choose how other users can add the current accountSet friend request permissions
Subscribe to, retrieve, and unsubscribe from online statusSubscribe to user online status, Get subscribed user online status, Unsubscribe from user status
Manage friends, friend requests, or the blacklistRelationship overview

State updates

Set the user listener for user-related state changes. See the corresponding capability pages below for details about each callback:

OpenIMClient client = OpenIMClient.getInstance();

client.userInfoManager.setOnUserListener(new OnUserListener() {
    @Override
    public void onSelfInfoUpdated(UserInfo info) {
        // Handle current-user profile changes.
    }

    @Override
    public void onUserStatusChanged(UsersOnlineStatus status) {
        // Handle user online-status changes.
    }
});