Getting a Member List of a Group

A group owner and members can get a list of members of the group with the listMembers() method. This method will return a list of KiiUser instances representing group members.

Note that the KiiUser instance returned by the method only contains the ID. Execute the refresh() method to get the user's latest information from Kii Cloud.

If the returned user is different from the logged-in user, available user information is limited. For more information, see User Attributes.

Here's an example:

  • try {
      // Get a list of members of the group.
      List<KiiUser> members = group.listMembers();
    
      for (KiiUser groupMember : members) {
        // Refresh the member to retrieve the latest data from Kii Cloud.
        groupMember.refresh();
    
        // Do something.
      }
    } catch (GroupOperationException e) {
      // Handle the error.
    }
  • // Get a list of members of the group.
    group.listMembers(new KiiGroupCallBack() {
      @Override
      public void onListMembersCompleted(int token, final List<KiiUser> members, KiiGroup group, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
        if (members.size() <= 0) {
          return;
        }
    
       // Refresh the member to retrieve the latest data from Kii Cloud.
        members.get(0).refresh(new KiiUserCallBack() {
          private int index = 0;
    
          @Override
          public void onRefreshCompleted(int token, Exception exception) {
            if (exception != null) {
              // Handle the error.
              return;
            }
    
            KiiUser groupMember = members.get(index);
            // Do something.
    
            // Refresh the next member.
            if (++index >= members.size()) {
              return;
            }
            KiiUser nextMember = members.get(index);
            nextMember.refresh(this);
          }
        });
      }
    });