Assigning contacts to a group

Sometimes when calling Roster.createEntry( jabberId, “Alias”, new String[] { “Group” } ); on for a contact that is already in the Roster but in no group and that has no alias will only give the contact an Alias, but not move them to the “Group” group. They will simply be aliased to “Alias”, but remain in no Group. Here’‘s what the smack debug window says I’'m sending:

<iq id="6I4Od-5" type="set"><query xmlns="jabber:iq:roster"><item jid="itneyway%hotmail.com@msn.jabber.hawkesnest.net" name="whitney"><group>friends</group></item></query></iq>
<presence id="6I4Od-7" to="itneyway%hotmail.com@msn.jabber.hawkesnest.net" type="subscribe"></presence>
<iq id="6I4Od-8" type="set"><query xmlns="jabber:iq:roster"><item jid="itneyway%hotmail.com@msn.jabber.hawkesnest.net" name="whitney" subscription="both"></item></query></iq>
<iq id="6I4Od-9" type="get"><query xmlns="jabber:iq:roster"></query></iq>

And here’'s what I get back from the server:

<iq type=''set''><query xmlns=''jabber:iq:roster''>
<item jid=''itneyway%hotmail.com@msn.jabber.hawkesnest.net'' name=''whitney'' subscription=''both''><group>friends</group></item></query></iq><iq id=''6I4Od-5'' type=''result'' from=''synic@linuxhelp.homeunix.com/work'' to=''synic@linuxhelp.homeunix.com/work''/>
<iq type=''set''><query xmlns=''jabber:iq:roster''><item jid=''itneyway%hotmail.com@msn.jabber.hawkesnest.net'' name=''whitney'' subscription=''both''/></query></iq>
<iq id=''6I4Od-8'' type=''result'' from=''synic@linuxhelp.homeunix.com/work'' to=''synic@linuxhelp.homeunix.com/work''/><iq id=''6I4Od-9'' type=''result'' from=''synic@linuxhelp.homeunix.com/work''><query xmlns=''jabber:iq:roster''>

Any ideas?

Adam,

The reason why your entry is kept unfiled is because the third packet that you sent specifies that the roster entry won’'t belong to any group.

Your first packet sets a new name and request the server to add the entry to a new group. Your second packet requests a subscription to the user’‘s presence. I don’'t know why but your third packet requests the server to remove the entry from any group. What was your intention with this packet? Are you trying to remove the entry from the group in any part of your code or creating the entry again but with no group?

It will help if you could paste the timestamps of the sent and received packets. My best guess (of a possible problem) is that you are sending the third packet (for X reason) before Smack can actually process the notification from the server about your first packet.

Regards,

– Gato

Hrmm. What I’‘m doing right after is running Entry.setName on the entry (which is something I don’'t need to do). My bad

Adam