SDKsAndroid
Relationship overview
Learn about friends, friend requests, and blacklist APIs in the Android SDK.
Relationships record friendships, friend requests, and blacklist entries between the current user and other users. Profiles, account settings, and online status belong to user capabilities. See User overview.
Relationship objects
Android SDK returns different objects for relationship scenarios:
| Type | Use case | Main APIs |
|---|---|---|
UserInfo | User profile and relationship data in friend lists, specified-friend queries, and the blacklist | getFriendListPage(), getFriendsInfo(), getBlacklist() |
FriendInfo | Friend profiles, remarks, and relationship extension data | UserInfo.getFriendInfo(), searchFriends() |
FriendshipInfo | Friendship result between the current user and a target user | checkFriend() |
FriendApplicationInfo | Received and sent friend requests and their handling status | getRecvFriendApplicationList(), getSendFriendApplicationList() |
BlacklistInfo | Blacklist relationship data | UserInfo.getBlackInfo(), getBlacklist() |
UserInfo can contain friend or blacklist relationship data. Call getFriendInfo() to obtain FriendInfo, or getBlackInfo() to obtain BlacklistInfo.
Feature entry points
| Requirement | Recommended page |
|---|---|
| Page through, search, or retrieve specified friend profiles | Get the friend list by page, Search friends, Get specified friend profiles |
| Check the friendship between the current user and a target user | Check friendship |
| Update or delete a friend relationship | Update friend profiles, Delete a friend |
| Send, retrieve, accept, or reject friend requests | Send a friend request, Get received friend requests, Get sent friend requests, Accept a friend request, Reject a friend request |
| View or maintain the blacklist | Get the blacklist, Block a user, Unblock a user |
State updates
Set the friendship listener for relationship state changes. See the corresponding capability pages below for details about each callback:
OpenIMClient client = OpenIMClient.getInstance();
client.friendshipManager.setOnFriendshipListener(new OnFriendshipListener() {
@Override
public void onFriendApplicationAdded(FriendApplicationInfo application) {
// Handle friend request changes.
}
@Override
public void onFriendApplicationAccepted(FriendApplicationInfo application) {
// Handle an accepted friend request.
}
@Override
public void onFriendApplicationRejected(FriendApplicationInfo application) {
// Handle a rejected friend request.
}
@Override
public void onFriendApplicationDeleted(FriendApplicationInfo application) {
// Handle friend request deletion.
}
@Override
public void onFriendAdded(FriendInfo friend) {
// Handle friendship changes.
}
@Override
public void onFriendInfoChanged(FriendInfo friend) {
// Handle friend profile changes.
}
@Override
public void onFriendDeleted(FriendInfo friend) {
// Handle friendship deletion.
}
@Override
public void onBlacklistAdded(BlacklistInfo user) {
// Handle a new blacklist entry.
}
@Override
public void onBlacklistDeleted(BlacklistInfo user) {
// Handle blacklist entry deletion.
}
});- Friend request changes: Get received friend requests.
- Friendship and friend profile changes: Get the friend list by page.
- Blacklist changes: Get the blacklist.
Was this page helpful?