powered by Jive Software

Create a new group


I want to add a new group to the roster,using connection.getRoster().createGroup(“new group”).

Yes, it is done successfully. however, when I sign out and sign in again the new group seems to dispear.

What is the problem? Thank you very much!


I’'m adding the following note to the Javadoc on the createGroup method:

Note: you must add at least one entry to the group for the group to be kept after a login/logout. This is due to the way that XMPP stores group information.

If you turn on Smack debugging, you’‘ll see how group information is transmitted. A roster is always a flat list of XMPP addresses, with the list of groups that each entry belongs to as an attribute. So, if at least one user doesn’'t belong to a group then there is no place to store info about that group. I hope that helps!



Thank you so much for ur quick reply, matt.

it is quite helpful.

Hi ,Matt, one more qusetion.

there is a method getName() in the class RosterEntry,which returns something like nickname,doesnt it?

Then how can I create this kind name for the login account.I cannot find it in the AccountManager.


A user doesn’‘t get to determine what their own name is in someone else’'s roster. Instead, when you add someone to your roster, you give them a name.

I just looked over the Roster and RosterGroup API’‘s and this may not be very clear. I’'m going to add a few methods such as:

public void addEntry(String XMPPAddress);

public void addEntry(String XMPPAddress, String name);

That first method will just make the name of the roster entry be the person’'s username (so, jsmith in the address jsmith@example.com).

There are a couple of JEP’‘s in development by the JSF that address user profile data in a more general way, including by using vcards. When one of those methods becomes the standard, I’'ll improve the AccountManager class to expose that information.