roster.getEntries() error

I’'m getting an error with roster.getEntries()

I was trying something like the example in http://www.igniterealtime.org/builds/smack/docs/latest/documentation/roster.html but it doesn’'t work…

Roster roster = con.getRoster();

for (Iterator i=roster.getEntries(); i.hasNext(); ) {

System.out.println(i.next());

}

I also have an other problem with

final Roster roster = con.getRoster();

roster.addRosterListener(new RosterListener() {

public void rosterModified() {

// Ignore event for this example.

}

public void presenceChanged(String user) {

+// If the presence is unavailable then “null” will be printed,

// which is fine for this example.+

System.out.println("Presence changed: " + roster.getPresence(user));

}

});

it says: The type new RosterListener(){} must implement the inherited abstract method RosterListener.entriesUpdated(Collection<String>)

what I’'m supposed to do?

Message was edited by: alucard

For the first part to compile, you should have something like this:

Roster roster = con.getRoster();

for (RosterEntry entry : roster.getEntries() ) {

System.out.println(entry);

}

For the second part to compile, you should have something like this:

final Roster roster = con.getRoster();

roster.addRosterListener(new RosterListener() {

public void entriesAdded(Collection addresses) {

// Ignore event for this example.

}

public void entriesDeleted(Collection addresses) {

// Ignore event for this example.

}

public void entriesUpdated(Collection addresses) {

// Ignore event for this example.

}

public void presenceChanged(Presence presence) {

// If the presence is unavailable then “null” will be printed,

// which is fine for this example.

System.out.println("Presence changed: " + presence);

}

});

The API for these examples changed in Smack 3.0.0 and it seems the documentation was not updated to match the changes. For the latest version of the API you should use, checkout the JavaDoc here:

Smack JavaDoc

Hope that helps,

Chris