Android Smack Unfriend Request
public static void sendFriendshipRequest(EntityBareJid toJid , String name, String stanzaID) throws SmackException.NotConnectedException, InterruptedException {
Presence presence = new Presence(Presence.Type.unsubscribe);
presence.setTo(toJid);
presence.setFrom(fromJid);
presence.setStanzaId(stanzaID);
mConnection.sendStanza(presence);
mConnection.addStanzaSendingListener(new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
Presence presence = (Presence) packet;
Presence.Mode mode = presence.getMode();
// Toast.makeText(act, "Un friend succefully " +name, Toast.LENGTH_SHORT).show();
if (mode == null) return;
switch (mode) {
case available:
case chat:
// We assume that only a switch to available and chat indicates user activity
// since other mode changes could be also a result of some sort of automatism
break;
default:
break;
}
}
}, StanzaTypeFilter.PRESENCE);
}
No comments:
Post a Comment