Smack错误地显示在线/离线状态

时间:2012-12-24 02:47:56

标签: openfire smack

这是我在线显示当前用户朋友的代码。

        final String me = "hieugioi@xxx.xxx.x.xx";
        connection.connect();
        connection.login(me, "123456");
        final Roster roster = connection.getRoster();

    final Collection<RosterEntry> entries = roster.getEntries();
    for(final RosterEntry entry : entries) {
        System.out.println("User: " + entry.getUser());
        System.out.println("Name: " + entry.getName());
        //System.out.println("Status: " + entry.getStatus());


        final Presence p = roster.getPresence(entry.getUser());
        System.out.println("====== Mode: " + p.getMode());
        System.out.println("====== Status: " + p.getStatus());
    }

日志显示

12-24 09:37:18.029: I/System.out(2831): User: hieungoan@xxx.xxx.x.xx
12-24 09:37:18.029: I/System.out(2831): Name: hieungoan
12-24 09:37:18.029: I/System.out(2831): ====== Mode: null
12-24 09:37:18.029: I/System.out(2831): ====== Status: null
12-24 09:37:18.029: I/System.out(2831): User: hieutot@xxx.xxx.x.xx
12-24 09:37:18.029: I/System.out(2831): Name: hieutot
12-24 09:37:18.029: I/System.out(2831): ====== Mode: null
12-24 09:37:18.029: I/System.out(2831): ====== Status: null
12-24 09:37:18.029: I/System.out(2831): User: hieuhay@xxx.xxx.x.xx
12-24 09:37:18.029: I/System.out(2831): Name: hieuhay
12-24 09:37:18.029: I/System.out(2831): ====== Mode: null
12-24 09:37:18.029: I/System.out(2831): ====== Status: null
12-24 09:37:18.029: I/System.out(2831): User: hieukhoe@xxx.xxx.x.xx
12-24 09:37:18.029: I/System.out(2831): Name: hieukhoe
12-24 09:37:18.029: I/System.out(2831): ====== Mode: null
12-24 09:37:18.029: I/System.out(2831): ====== Status: null

事实上,用户hieutothieungoan在Openfire中在线,但它始终显示为NULL!我的代码出了什么问题?

1 个答案:

答案 0 :(得分:0)