// Display the presence
if (activity.getActor().getUri().equals(service.getUserBareJID())) {
setPresence(service.getPresence());
} else {
final RosterItem rosterItem = service.getRoster().getItem(
activity.getActor().getUri());
if (rosterItem != null) {
setPresence(rosterItem.getPresence());
rosterItem.registerEventHandler(new Observer<RosterEvent>() {
@Override
public void handleEvent(RosterEvent event) {
setPresence(rosterItem.getPresence());
}
});
}
}