ricky khatri ricky khatri - 1 year ago 94
Android Question

android smack subscribe user not working

i am using below code to send friend request to any user its working fine but i am not able to find the connected user from roster list.

Now i want to know how could i identify new requested friend in roster list.

Roster roster = XMPPSmackConnection.getInstance().connection.getRoster();
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
try {
if(!_userName.contains("@"))
_userName=_userName+"@204.93.197.136";

Presence response = new Presence(Presence.Type.subscribe);
response.setTo(_userName);
XMPPSmackConnection.getInstance().connection.sendPacket(response);

//roster.createEntry(_userName, _nickName, my_friends[]);
//addBuddy(_userName, _nickName, Friends);
} catch (Exception e) {
_progDailog.dismiss();
e.printStackTrace();
}

Answer Source

I have been trying to resolve a similar issue where the Roster List does not updated on accepting a friend's request. Steps followed :-

  1. Sent a friend request using Presence type as subscribe
  2. At the other end, while accepting the friend's request, a subscribed presence type is sent
  3. On receiving the subscribed Presence packet, another subscribed packet is sent back.

The server's roster list gets updated immediately by Subscription type as Both but the roster entries are not. Also, the roster's subscription Mode is set to manual and it also has a PacketListener attached to it.

Please can you provide some help by contributing your solution to this problem? It would be of great help.

Thanks and Regards, Vaidehi

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download