Getting a Group List for a Member

Users can get a list of groups that they are a member of.

The following sample code shows how to get a list of groups that the current user is a member of.

  • // Get the currently logged-in user.
    KiiUser user = KiiUser.getCurrentUser();
    
    try {
      // Get a list of groups that the current user is a member of.
      List<KiiGroup> memberGroups = user.memberOfGroups();
    
      for (KiiGroup group : memberGroups) {
        // Do something.
      }
    } catch (IOException e) {
      // Handle the error.
    } catch (AppException e) {
      // Handle the error.
    }
  • // Get the currently logged-in user.
    KiiUser user = KiiUser.getCurrentUser();
    
    // Get a list of groups that the current user is a member of.
    user.memberOfGroups(new KiiUserCallBack() {
      @Override
      public void onMemberOfGroupsCompleted(int token, KiiUser user, List<KiiGroup> groupList, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
    
        for (KiiGroup group : groupList) {
          // Do something.
        }
      }
    });