Android with Smack -How to get list of online users?
<p>I am working with <strong>jivesoftware Smack SDk</strong> for real time chatting functionality.
For creating connection I am using following code , </p>

<pre><code>XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

    config.setServiceName("world-pc");
    config.setHost(serverAddress);
    config.setPort(5222);
    config.setDebuggerEnabled(true);
    XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
    XMPPTCPConnection.setUseStreamManagementDefault(true);
    connection = new XMPPTCPConnection(config.build());
    XMPPConnectionListener connectionListener = new XMPPConnectionListener();
    connection.addConnectionListener(connectionListener);
    connection.connect();
    connection.login("username","password");
</code></pre>

<p>And its working amazingly fine.
Now the thing is that, I want to get online status of particular user or to get list of all users who are online.
I have tried many solutions from stack overflow, but nothing works for me.
One of my solution which I tried is,</p>

<pre><code>Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
Roster roster = xmppConnection.getRoster();
Collection&lt;RosterEntry&gt; entries = roster.getEntries();
Presence presence;

for(RosterEntry entry : entries) {
presence = roster.getPresence(entry.getUser());

System.out.println(entry.getUser());
System.out.println(presence.getType().name());
System.out.println(presence.getStatus());
 }
</code></pre>

<p>This returns me a list, but the status is null for all users.
Please some one help me with accurate solution.</p>

<p>Thank you</p>