【问题标题】:Roster.getEntries returning 0 with asmackRoster.getEntries 使用 asmack 返回 0
【发布时间】:2015-10-19 09:00:20
【问题描述】:

我创建了一个sendchat短信,但是我无法通过roster方法获取其他用户的状态。

Roster roster = connection.getRoster();

                Log.e("entry count",""+roster.getEntryCount());

                Collection<RosterEntry> entries = roster.getEntries();
                Log.e("Roster Entries",""+roster.getEntries().size());
                for (RosterEntry entry : entries) {
                    Presence.Type type = entryPresence.getType();
                    if (type == Presence.Type.available)
                        Log.e("XMPPChatDemoActivity", "Presence AVIALABLE");                
                }



            } catch (XMPPException ex) {

                setConnection(null);

}

【问题讨论】:

    标签: android xmpp openfire asmack


    【解决方案1】:

    你需要添加:

    If(!Roster.IsLoaded()) 
       Roster.reloadAndWait();
    

    行前:

    Collection<RosterEntry> entries = roster.getEntries();
    

    【讨论】:

    • 这仍然给我 0 个条目
    • 你也需要在openfire中添加订阅
    【解决方案2】:

    没有将用户添加到名册列表中。仅将用户添加到名册列表后,我们可以获取用户详细信息。

    【讨论】:

    • 添加名册还不够,还需要添加订阅。
    猜你喜欢
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    相关资源
    最近更新 更多