Adding and Removing a Member
Users can be added to groups and removed from groups.
Adding a member
A group owner can add additional members to their group with the addUser()
method:
-
// Instantiate a user. Uri userUri = Uri.parse("Set the URI of an existing user here"); KiiUser user2 = KiiUser.createByUri(userUri); // Add the user to the group. group.addUser(user2); try { // Save the group on the server. group.save(); } catch (GroupOperationException e) { // Handle the error. }
-
// Instantiate a user. Uri userUri = Uri.parse("Set the URI of an existing user here"); KiiUser user2 = KiiUser.createByUri(userUri); // Add the user to the group. group.addUser(user2); // Save the group on the server. group.save(new KiiGroupCallBack() { @Override public void onSaveCompleted(int token, KiiGroup group, Exception exception) { if (exception != null) { // Handle the error. return; } } });
Make sure to execute the save()
method to reflect the changes.
Removing a member
A group owner can remove existing members from their group with the removeUser()
method.
-
// Instantiate a user. Uri userUri = Uri.parse("Set the URI of an existing user here"); KiiUser user2 = KiiUser.createByUri(userUri); // Remove the user from the group. group.removeUser(user2); try { // Save the group on the server. group.save(); } catch (GroupOperationException e) { // Handle the error. }
-
// Instantiate a user. Uri userUri = Uri.parse("Set the URI of an existing user here"); KiiUser user2 = KiiUser.createByUri(userUri); // Remove the user from the group. group.removeUser(user2); // Save the group on the server. group.save(new KiiGroupCallBack() { @Override public void onSaveCompleted(int token, KiiGroup group, Exception exception) { if (exception != null) { // Handle the error. return; } } });
Make sure to execute the save()
method to reflect the changes.