Unable to obtain list of all available users


I’m a newbie. I’m developing an anonymous chat app for android. I’m unable to retrieve all users available using roster.getEntries(), even if users are

available. I tried putting the thread to sleep for 20 seconds but it doesn’t work. Here’s the snapshot of my code

In this code i’m trying to retrieve all available users

public void setConnection (XMPPConnection connection) throws XMPPException


if (connection != null)


//subitems = new ArrayList();

roster = connection.getRoster();


Log.d(“Roster”, “Roster”+roster.getEntryCount());

roster.addRosterListener(new RosterListener()


public void presenceChanged(Presence arg0)


and in this code segment i’m trying to retrieve all available users

entries = roster.getEntries();

Log.d(“Inside ReloadList”, “Contains”+entries.size());

for (RosterEntry entry : entries)