User profiles
This guide explains how to manage user profiles with the Nexconn SDK for Android, including setting, querying, subscribing, and listening for profile changes.
Manage user profiles
You can update your own profile, retrieve your profile, or query profiles for multiple users in bulk.
Update your profile
Use NCEngine.userModule.updateMyUserProfile() with UserProfile to update the current user's profile.
By default, profile data is not subject to content moderation. To enable moderation, configure the relevant profile moderation option in the Console under Chat > Chat settings > Security & Moderation.
Parameters (UserProfile)
| Property | Type | Description |
|---|---|---|
name | String? | Nickname. Max 32 characters. |
portraitUri | String? | Avatar URL. Max 128 characters. |
email | String? | Email. Max 128 characters. |
birthday | String? | Birthday. Max 32 characters. |
gender | Int? | Gender: 0 = unknown, 1 = male, 2 = female. |
location | String? | Location. Max 32 characters. |
role | Int? | Role. Range: 0–100. |
level | Int? | Level. Range: 0–100. |
- Kotlin
- Java
val profile = UserProfile(
name = "New Nickname",
portraitUri = "https://example.com/avatar.png",
gender = 1 // 1 = male
)
NCEngine.userModule.updateMyUserProfile(profile) { errorKeys, error ->
if (error == null) {
// Updated successfully
} else {
// Failed — errorKeys contains keys that failed
}
}
UserProfile profile = new UserProfile(
null, "New Nickname", "https://example.com/avatar.png",
null, null, null, 1, null, null, null, null
);
NCEngine.userModule.updateMyUserProfile(profile, (errorKeys, error) -> {
if (error == null) {
// Updated successfully
} else {
// Failed
}
});
Get your profile
Use NCEngine.userModule.getMyUserProfile() to retrieve the current user's profile.
- Kotlin
- Java
NCEngine.userModule.getMyUserProfile { profile, error ->
if (error == null && profile != null) {
println("Name: ${profile.name}, Avatar: ${profile.portraitUri}")
}
}
NCEngine.userModule.getMyUserProfile((profile, error) -> {
if (error == null && profile != null) {
System.out.println("Name: " + profile.getName());
}
});
Get profiles in bulk
Use NCEngine.userModule.getUserProfiles() to retrieve profiles for specific users by userId.
You can query up to 20 users per call.
- Kotlin
- Java
val userIds = listOf("user1", "user2", "user3")
NCEngine.userModule.getUserProfiles(userIds) { profiles, error ->
if (error == null && profiles != null) {
profiles.forEach { profile ->
println("User: ${profile.userId}, Name: ${profile.name}")
}
}
}
List<String> userIds = Arrays.asList("user1", "user2", "user3");
NCEngine.userModule.getUserProfiles(userIds, (profiles, error) -> {
if (error == null && profiles != null) {
for (UserProfile profile : profiles) {
System.out.println("User: " + profile.getUserId());
}
}
});
Manage profile visibility
The Nexconn SDK provides APIs to set and retrieve user-level profile visibility using the UserProfileVisibility enum.
UserProfileVisibility enum values:
| Value | Description |
|---|---|
UserProfileVisibility.NOT_SET | Not set. Follows the app-level setting (default). |
UserProfileVisibility.INVISIBLE | Hidden. No one can view the user's profile (except name and avatar). |
UserProfileVisibility.EVERYONE | Public. Any user in the app can view the profile. |
UserProfileVisibility.FRIEND_VISIBLE | Friends only. Only users on the friend list can view the profile. |
Visibility behavior
The default app-level profile visibility is Hidden. The default user-level visibility is Not set. When both are at their default values, other users can only see the user's name and avatar.
| App-level visibility | User-level visibility | Result |
|---|---|---|
| Hidden, Friends only, or Public | Not set | App-level setting applies |
| Hidden, Friends only, or Public | Set to Hidden, Friends only, or Public | User-level setting applies |
Set profile visibility
Use NCEngine.userModule.updateMyUserProfileVisibility() to set your profile visibility.
- Kotlin
- Java
NCEngine.userModule.updateMyUserProfileVisibility(UserProfileVisibility.EVERYONE) { error ->
if (error == null) {
// Visibility updated
}
}
NCEngine.userModule.updateMyUserProfileVisibility(UserProfileVisibility.EVERYONE, error -> {
if (error == null) {
// Visibility updated
}
});
Get profile visibility
Use NCEngine.userModule.getMyUserProfileVisibility() to retrieve your current profile visibility setting.
- Kotlin
- Java
NCEngine.userModule.getMyUserProfileVisibility { visibility, error ->
if (error == null && visibility != null) {
println("Current visibility: $visibility")
}
}
NCEngine.userModule.getMyUserProfileVisibility((visibility, error) -> {
if (error == null && visibility != null) {
System.out.println("Current visibility: " + visibility);
}
});
Subscribe to profile and visibility changes
Listen for subscription events
To receive profile change notifications, use NCEngine.addUserHandler().
Handle events based on the SubscribeType. For user profile events, the type is SubscribeType.USER_PROFILE.
- Kotlin
- Java
NCEngine.addUserHandler("PROFILE_HANDLER", object : UserHandler {
override fun onSubscriptionChanged(event: SubscriptionChangedEvent) {
if (event.subscribeType == SubscribeType.USER_PROFILE) {
event.events.forEach { info ->
println("Profile changed for user: ${info.userId}")
}
}
}
override fun onSubscriptionSyncCompleted(event: SubscriptionSyncCompletedEvent) {
if (event.subscribeType == SubscribeType.USER_PROFILE) {
// Profile subscription sync complete
}
}
override fun onSubscriptionChangedOnOtherDevices(event: SubscriptionChangedOnOtherDevicesEvent) {
event.events.forEach { info ->
println("Subscription changed on other device: ${info.userId}")
}
}
})
NCEngine.addUserHandler("PROFILE_HANDLER", new UserHandler() {
@Override
public void onSubscriptionChanged(@NonNull SubscriptionChangedEvent event) {
if (event.getSubscribeType() == SubscribeType.USER_PROFILE) {
for (SubscribeStatusInfo info : event.getEvents()) {
System.out.println("Profile changed for user: " + info.getUserId());
}
}
}
@Override
public void onSubscriptionSyncCompleted(@NonNull SubscriptionSyncCompletedEvent event) {
if (event.getSubscribeType() == SubscribeType.USER_PROFILE) {
// Profile subscription sync complete
}
}
@Override
public void onSubscriptionChangedOnOtherDevices(@NonNull SubscriptionChangedOnOtherDevicesEvent event) {
for (SubscribeChangeEvent info : event.getEvents()) {
System.out.println("Subscription changed on other device: " + info.getUserId());
}
}
});
Subscribe to profile changes
Use NCEngine.userModule.subscribeEvent() with SubscribeEventParams to track profile and visibility changes for other users.
- Up to 200 users per subscription call.
- Maximum total subscriptions: 1,000 users.
- Each user can be subscribed to by up to 5,000 users.
- Subscription duration: 60 to 2,592,000 seconds.
Kotlin example (recommended)
- Kotlin
- Java
val params = SubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
expiry = 180000,
userIds = listOf("user1", "user2", "user3")
)
NCEngine.userModule.subscribeEvent(params) { failedIds, error ->
if (error == null) {
// Subscribed successfully
} else {
// failedIds contains user IDs that failed
}
}
SubscribeEventParams params = new SubscribeEventParams(
SubscribeType.USER_PROFILE,
180000,
Arrays.asList("user1", "user2", "user3")
);
NCEngine.userModule.subscribeEvent(params, (failedIds, error) -> {
if (error == null) {
// Subscribed successfully
}
});
Unsubscribe from profile changes
Use NCEngine.userModule.unsubscribeEvent() to stop tracking profile changes. You can unsubscribe up to 200 users per call.
- Kotlin
- Java
val params = UnsubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
userIds = listOf("user1", "user2", "user3")
)
NCEngine.userModule.unsubscribeEvent(params) { failedIds, error ->
if (error == null) {
// Unsubscribed successfully
}
}
UnsubscribeEventParams params = new UnsubscribeEventParams(
SubscribeType.USER_PROFILE,
Arrays.asList("user1", "user2", "user3")
);
NCEngine.userModule.unsubscribeEvent(params, (failedIds, error) -> {
if (error == null) {
// Unsubscribed successfully
}
});
Query subscription status for specific users
Use NCEngine.userModule.getSubscribeEvent() to check the profile subscription status of specific users. You can query up to 200 users at a time.
- Kotlin
- Java
val params = GetSubscribeEventParams(
subscribeType = SubscribeType.USER_PROFILE,
userIds = listOf("user1", "user2", "user3")
)
NCEngine.userModule.getSubscribeEvent(params) { subscribeInfoList, error ->
if (error == null && subscribeInfoList != null) {
subscribeInfoList.forEach { info ->
println("Subscribed user: ${info.userId}, expires: ${info.expiry}")
}
}
}
GetSubscribeEventParams params = new GetSubscribeEventParams(
SubscribeType.USER_PROFILE,
Arrays.asList("user1", "user2", "user3")
);
NCEngine.userModule.getSubscribeEvent(params, (subscribeInfoList, error) -> {
if (error == null && subscribeInfoList != null) {
for (SubscribeStatusInfo info : subscribeInfoList) {
System.out.println("Subscribed user: " + info.getUserId() + ", expires: " + info.getExpiry());
}
}
});
List profile subscriptions (paginated)
Use NCEngine.userModule.createSubscribeQuery() with SubscribeQueryParams to retrieve all profile subscription events with pagination.
- Kotlin
- Java
val params = SubscribeQueryParams(SubscribeType.USER_PROFILE).apply {
pageSize = 20
}
val query = NCEngine.userModule.createSubscribeQuery(params)
query.loadNextPage { page, error ->
if (error == null && page != null) {
page.data.forEach { info ->
println("Subscribed user: ${info.userId}")
}
if (page.hasMore) {
// Fetch next page
}
}
}
SubscribeQueryParams params = new SubscribeQueryParams(SubscribeType.USER_PROFILE);
params.setPageSize(20);
SubscribeQuery query = NCEngine.userModule.createSubscribeQuery(params);
query.loadNextPage((page, error) -> {
if (error == null && page != null) {
for (SubscriptionStatusInfo info : page.getData()) {
System.out.println("Subscribed user: " + info.getUserId());
}
if (page.getHasMore()) {
// Fetch next page
}
}
});