Android based OpenFire Development Instant Messaging Tool (4) Get buddy list

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.