Reputation: 45
I'm developing a simple chat for Android. I'm reading about Openfire ante asmack API. Obviously the user should see only the contacts stored in his device, so: How can I know which contacts stored in the server are my device contacts? or, how can I assign to a contact the contacts that he have in his device? I've see that it can be done in the Admin console, but by code? It's the last thing I need to know to start developing it.
Thanks in advance.
Upvotes: 1
Views: 689
Reputation: 3880
Try this:
// Create the configuration for this new connection
ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
Connection connection = new XMPPConnection(config);
// Connect to the server
connection.connect();
// Log into the server
connection.login("danilodeveloper", "password", "SomeResource");
// getting the Openfire contacts that danilodeveloper has
Roster roster = connection.getRoster();
// the contacts
Collection<RosterEntry> entries = roster.getEntries();
With the entries (for example entrie.getUser()), you can compare the Openfire contacts with the device contacts.
Cheers
Upvotes: 2