Skip to main content

tip

This feature is supported starting from version 5.12.0.

User Profile Page

The User Profile Page displays basic user information. Upon entering this page, the SDK retrieves user data from the database and presents it.

Note: The IMKit chat UI does not automatically navigate to the User Profile Page. Developers who wish to use this feature must manually implement event listeners (e.g., avatar clicks) in the conversation interface and handle the redirection logic.

Enable the Service

Before using this feature, you must activate User Profile Hosting in the Console.

Current User Profile Page

The Current User Profile Page includes a header section and detailed user information (avatar, nickname, application ID, gender, etc.).

The MyProfile page displays and manages the current user's personal information, allowing users to view and modify their avatar, nickname, gender, and other details. Below are detailed descriptions of the components related to the MyProfile page:

  • MyProfileActivity: The container class for the personal information page, responsible for loading and displaying MyProfileFragment.
  • MyProfileFragment: The core component of the personal information page, responsible for displaying user details and handling click events to navigate to corresponding edit pages.
  • MyProfileViewModel: Handles data and business logic, retrieves the current user's information from the server, and passes it to MyProfileFragment.
  • XML Layout: rc_page_my_profile.xml

Launch the Current User Profile Page

  startActivity(MyProfileActivity.newIntent(getContext()))

Customization

Refer to User Profile Hosting Page Design for custom Fragment implementation.

public class CustomMyProfileFragment extends MyProfileFragment {

@Override
protected void onViewReady(@NonNull MyProfileViewModel viewModel) {
super.onViewReady(viewModel);
// Modify the header title
headComponent.setTitleText("New Title");

// Override the back button click event
headComponent.setLeftClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});
}

// Handle avatar click
@Override
protected void onUserHeaderClick(View view) {
Toast.makeText(
getContext(),
"Custom avatar upload logic",
Toast.LENGTH_SHORT)
.show();
}
}

Other User Profile Page

The UserProfile page displays detailed information about other users, including their avatar, nickname, relationship status (e.g., whether they are friends), and provides actions such as adding friends, initiating chats, or removing friends. Below are detailed descriptions of the components related to the UserProfile page:

  • UserProfileActivity: The container class for the user details page, responsible for loading and displaying UserProfileFragment.
  • UserProfileFragment: The core component of the user details page, responsible for displaying user information, friend-related action buttons, and handling user interactions.
  • UserProfileViewModel: Handles data and business logic, retrieves user details, manages friend relationships, and passes data to UserProfileFragment.
  • XML Layout: rc_page_user_profile.xml

Launch Another User's Profile Page

  String userId = "123";
startActivity(UserProfileActivity.newIntent(getContext()),userId)

Customization

Refer to User Profile Hosting Page Design for custom Fragment implementation.

public class UserProfileFragment extends BaseViewModelFragment<UserProfileViewModel> {

protected HeadComponent headComponent; // Header component containing back button and page title.
protected Button btnStartChat; // "Start Chat" button to initiate a conversation with the user.
protected Button btnStartAudio; // "Start Audio Call" button to initiate a voice call with the user.
protected Button btnStartVideo; // "Start Video Call" button to initiate a video call with the user.
protected Button btnDeleteUser; // "Remove Friend" button to delete the user from the friend list.
protected Button btnAddFriend; // "Add Friend" button to send a friend request.

}
// Customize click events based on views in UserProfileFragment
public class CustomUserProfileFragment extends UserProfileFragment {

@Override
protected void onViewReady(@NonNull UserProfileViewModel viewModel) {
super.onViewReady(viewModel);
// Modify the header title
headComponent.setTitleText("New Title");

// Override the back button click event
headComponent.setLeftClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});
}

}