powered by Jive Software

getRoster() method in Roster Class

Hi,

I am using the Smack API’s to implement a chat application, I have a problem, When i log in for the first time and call getRoster() method, I am getting all the roster items for the logged user, and after that if I call the getRoster() again I am not getting the same roster items which are loaded previously loaded, instead I shoul get the updated roster items from the database. Please help me in this regard.

Have a look at the RosterListener API documentation. It discriminates between newly added contacts and contacts that have changed.

Hi,

Thanks for the reply, Yes I am using the addRosterListener() method before doing the getRoster(), but then also I am getting the same Roster Items again.Please help me in this regard.

Ah, try switching the order, for example:

roster = con.getRoster();
        roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
        roster.addRosterListener(this);

This is after sending the initial presence. Basically, the last step in setting up the connection.