powered by Jive Software

Using smack api for GTalk, problem in getting online buddies

Hi all,

I am using the samck api to create a gtalk client in java. I was able to succesfully login, send messages and display contacts. But i have a problem with displaying online contacts. Something seems to be wrong with presence. I have attached my code below. Any help would be appreciated

public void onlineBuddies()
Roster roster = connection.getRoster();
Collection entries = roster.getEntries();
int count1 = 0;
int count2 = 0;
for(RosterEntry r:entries)
String user = r.getUser();
Presence presence = roster.getPresence(user);
if(presence.getType() == Presence.Type.unavailable)
//System.out.println(user + “is offline”);
System.out.println(user + “is online”);