这是我在线显示当前用户朋友的代码。
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
事实上,用户hieutot
和hieungoan
在Openfire中在线,但它始终显示为NULL!我的代码出了什么问题?