XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(Connection arg0) {
Log.i(TAG, "receive xmpp connection : " + arg0);
connection = arg0;
roster = arg0.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
Presence presence;
Log.e(TAG, "user count" + entries.size());
for (RosterEntry entry : entries) {
presence = roster.getPresence(entry.getUser());
Log.i(TAG, "" + entry.getUser());
Log.i(TAG, "" + presence.getType().name());
Log.i(TAG, "" + presence.getStatus());
}
}
});
So at the start of your program register that XMPPConnection listener, usually it take few seconds to receive connection object.
But it will work only if you will use creatEntry only in that case rooster will see those created users.
To creat entry using Roster use next code:
try {
rooster.createEntry("name", "user_id", null);
} catch (XMPPException e) {
e.printStackTrace();
}
I didn't use any group, and with success see user on second device.