質問

I'm using QuickBlox as BaaS. I would like to try getting user status. Are they online or not ? Found below useful question and I used Roster. Can I get online users in my friend list via Smack?

But When I retrieve by implementing following, get null entries.

Roster roster = xmppConnection.getRoster();
Collection<RosterEntry> 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());
    }
役に立ちましたか?

解決

In order to use this code you should add some users to your Roster (Contact list).

While adding some users - these users will receive Roster request and will be able to add you as well.

After that you Roster will contain some entries and you can iterate through it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top