Updating contacts presence

Hi, I need to update my contacts Presence.

I tried the following code from Gato. I always have a null presence for my contacts.

Somebody knows why?


Roster roster = connection.getRoster();

for (Iterator i=roster.getEntries(); i.hasNext(); ) {

RosterEntry entry = (RosterEntry)i.next();

Presence presence = roster.getPresence(entry.getUser());

System.out.println(entry + “\t” + presence);

}


Are the users you’‘re trying to retrieve the presence from currently online and connected? I’'m pretty sure your will retrieve a null presence if the user is not currently connected.

Hi ddman,

This is not only a null presence for disconnected contacts.

I’'ve got a null pointer for all contacts

Sorry ddman,

you were right. It works fine.

Some of my contacts are doubled on the server, but the code works right.

cheers

Glad to help