これは、現在のユーザーの友達の行をオンラインで表示するための私のコードです。
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
実際、ユーザーはOpenfire でオンラインですが、上記のように常に NULL が表示されhieutot
ます! コードの何が問題になっていますか?hieungoan