The previous section has set up a group in the OpenFire server,
This section continues to see how to get a buddy list,
Get roster through the connection object, so you can use Roster.getgroups () to get all the groups, using Group.getentries () to get all the users in the group
<span style= "White-space:pre" > </span>//get buddy list
Roster roster = Connection.getroster ();
collection<rostergroup> Entriesgroup = roster.getgroups ();
for (Rostergroup group:entriesgroup) {
collection<rosterentry> entries = group.getentries ();
LOG.I ("---", group.getname ());
for (Rosterentry entry:entries) {
//presence Presence = roster.getpresence (Entry.getuser ());
LOG.I ("---", "User:" +entry.getuser ());
LOG.I ("---", "Name:" +entry.getname ());
LOG.I ("---", "Tyep:" +entry.gettype ());
LOG.I ("---", "Status:" +entry.getstatus ());
LOG.I ("---", "Groups:" +entry.getgroups ());
The code is very simple, the following is the output:
With the name of the group and the Friends in the group, fill in the Baseexpandablelistadapter, so as to achieve a similar QQ friend group list,
These are implemented in another blog, do not repeat, the following is the portal:
Android High Imitation QQ friends list: http://blog.csdn.net/vestigge/article/details/8136418