8

Hi i am using smack.jar.I am able to connect with gtalk using it.Using Roster.getentries() i can get my buddy list.But how can i add new friends to my buddyList.Is there any API smack exposes to add new users??

Thanks

SPB
  • 4,040
  • 16
  • 49
  • 62

2 Answers2

11

I've been using this to create new contacts in a standard XMPP server (can't tell about gtalk):

  Roster roster = xmppConnection.getRoster();
  // jid: String, user: String, groups: String[]
  roster.createEntry(jid, user, groups);
Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
  • 2
    You'll probably want to listen for inbound subscription requests as well, since when you subscribe to someone, they often subscribe back. – Joe Hildebrand Oct 17 '10 at 02:57
  • 1
    how the friend will listen that he or she has been added to someones list or someone wants to add him as friend.. Please reply @JoeHildebrand – Gaurav Arora Oct 10 '12 at 09:43
5

In XMPP, adding is adding to your roster + subscribing to the user. Updating is just adding the user to your roster. Keep in mind the minutiae.

Tim
  • 1,084
  • 5
  • 10