Browse SDKs · Android
Platform
SDKsAndroidIncludes Enterprise features

Relationship overview

Understand friend management, friend applications, and blocklist APIs in the OpenIM Android SDK.

Copy

Relationship capabilities track friend connections, incoming/outgoing friend applications, and blocklists for the authenticated account. User profile details, account settings, and presence tracking belong to user capabilities; see User overview.

Relationship models

The Android SDK uses distinct models across relationship operations:

ClassApplication scenarioPrimary operations
UserInfoComprehensive user profile and relationship details in friend lists, profile lookups, and blocklistsGet the friend list, Get friend profiles, Get the blacklist
FriendInfoFriend metadata, remarks, and custom relationship extension fieldsAccessed via UserInfo.friendInfo, Search friends
FriendshipInfoCheck bilateral friendship state between the current user and a targetCheck friendship status
FriendApplicationInfoIncoming and outgoing friend applications along with their review statesGet received friend applications, Get sent friend applications
BlacklistInfoBlocklist entry informationAccessed via UserInfo.blackInfo, Get the blacklist

UserInfo contains comprehensive relation snapshots; access FriendInfo through the friendInfo property and BlacklistInfo through the blackInfo property.

TaskDocumentation page
Paginate, search, or query specific friend profilesGet the friend list, Search friends, Get friend profiles
Check friendship status with a target userCheck friendship status
Update friend remarks or delete a friendshipUpdate friend information, Delete a friend
Send, query, accept, or reject friend applicationsSend a friend application, Get received friend applications, Get sent friend applications, Accept a friend application, Refuse a friend application
View and manage the blocklistGet the blacklist, Block a user, Unblock a user

State updates

Relationship events are broadcast in real time through OnFriendshipListener. Deduplicate and incrementally merge friend records, friend applications, and blocklist entries using userID as the unique primary key:

OpenIMClient client = OpenIMClient.getInstance();

client.friendshipManager.setOnFriendshipListener(new OnFriendshipListener() {
    @Override
    public void onFriendApplicationAdded(FriendApplicationInfo application) {
        // Handle new friend application
    }

    @Override
    public void onFriendApplicationAccepted(FriendApplicationInfo application) {
        // Handle friend application accepted
    }

    @Override
    public void onFriendApplicationRejected(FriendApplicationInfo application) {
        // Handle friend application rejected
    }

    @Override
    public void onFriendApplicationDeleted(FriendApplicationInfo application) {
        // Handle friend application deleted
    }

    @Override
    public void onFriendAdded(FriendInfo friend) {
        // Handle new friend added
    }

    @Override
    public void onFriendInfoChanged(FriendInfo friend) {
        // Handle friend profile or remark changed
    }

    @Override
    public void onFriendDeleted(FriendInfo friend) {
        // Handle friend removed
    }

    @Override
    public void onBlacklistAdded(BlacklistInfo user) {
        // Handle user added to blocklist
    }

    @Override
    public void onBlacklistDeleted(BlacklistInfo user) {
        // Handle user removed from blocklist
    }
});