天天看點

smack4.2 傳回所有使用者資訊

Roster roster = Roster.getInstanceFor(conn);

public static List<RosterEntry> getAllEntries(Roster roster) throws NotLoggedInException, NotConnectedException, InterruptedException {

        List<RosterEntry> EntriesList = new ArrayList<RosterEntry>();

        if (!roster.isLoaded())

            roster.reloadAndWait();

        Collection <RosterEntry> entries = roster.getEntries();

        for (RosterEntry entry : entries) {

            System.out.println("Here: " + entry.getName());

            System.out.println("Here: " + entry.getGroups().get(0).getEntryCount());

            System.out.println("Here: " + entry.getJid().toString());

            EntriesList.add(entry);

        }

        return EntriesList;

    }