这是我在网上显示当前用户的朋友圈的代码。
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
和在 Openfirehieungoan
中在线,但它总是显示为 NULL,如上!我的代码有什么问题?