Relationship overview
Understand friend management, friend applications, and blocklist APIs in the OpenIM Android SDK.
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:
| Class | Application scenario | Primary operations |
|---|---|---|
UserInfo | Comprehensive user profile and relationship details in friend lists, profile lookups, and blocklists | Get the friend list, Get friend profiles, Get the blacklist |
FriendInfo | Friend metadata, remarks, and custom relationship extension fields | Accessed via UserInfo.friendInfo, Search friends |
FriendshipInfo | Check bilateral friendship state between the current user and a target | Check friendship status |
FriendApplicationInfo | Incoming and outgoing friend applications along with their review states | Get received friend applications, Get sent friend applications |
BlacklistInfo | Blocklist entry information | Accessed via UserInfo.blackInfo, Get the blacklist |
UserInfo contains comprehensive relation snapshots; access FriendInfo through the friendInfo property and BlacklistInfo through the blackInfo property.
Navigation by task
| Task | Documentation page |
|---|---|
| Paginate, search, or query specific friend profiles | Get the friend list, Search friends, Get friend profiles |
| Check friendship status with a target user | Check friendship status |
| Update friend remarks or delete a friendship | Update friend information, Delete a friend |
| Send, query, accept, or reject friend applications | Send a friend application, Get received friend applications, Get sent friend applications, Accept a friend application, Refuse a friend application |
| View and manage the blocklist | Get 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
}
});- Friend application updates: see Get received friend applications.
- Friend relationships and profile updates: see Get the friend list.
- Blocklist updates: see Get the blacklist.
Was this page helpful?