Currently I am Working chat applicaiton using Xmpp SMACK API.but when i have called addrosterListener then i am not getting Presence current status.I have to reference of http://www.igniterealtime.org/builds/smack/docs/3.2.2/javadoc/org/jivesoftware/smack/RosterListener.html .please help me.
roster.addRosterListener(new RosterListener() {
@Override
public void presenceChanged(Presence presence) {
Log.d("pewsence ", "pewsence Status: " + presence.getFrom());
Log.d("pewsence ", "pewsence to Status: "
+ presence.getTo() + " " + presence);
// Called when the presence of a roster entry is
// changed
}
@Override
public void entriesUpdated(Collection<String> arg0) {
// Called when a roster entries are updated.
}
@Override
public void entriesDeleted(Collection<String> arg0) {
// Called when a roster entries are removed.
}
@Override
public void entriesAdded(Collection<String> arg0) {
// Called when a roster entries are added.
}
});
}
}
});
this listener is call when activity created.I think refer to the all documents,this listener is called automatically when presense will change.
Thanks in advance.
roster = connection.getRoster();
// Get all rosters
Log.i("roster", "roster=" + connection.isConnected() + "-" + roster);
Collection<RosterEntry> entries = roster.getEntries();
// loop through
for (RosterEntry entry : entries) {
Presence entryPresence = roster.getPresence(entry.getUser());
Presence.Type userType = entryPresence.getType();
}
Using this code ,you have to get all online or offline users.and u can chat with anyone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With