AnsweredAssumed Answered

Block /UnBlock user using android

Question asked by shree on Jul 3, 2017

just, i have block the user following snippet code:

 

public void XMPPAddNewPrivacyList(XMPPConnection connection, String userName) {

  
String listName = "newList";
  
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();

  
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid,
  userName
,false, 1l);
  privacyItems
.add(item);
  
// Create the new list.

  
try {
  
PrivacyListManager privacyManager;
  privacyManager
= PrivacyListManager
  
.getInstanceFor(connection);
  privacyManager
.createPrivacyList(listName, privacyItems);

  
} catch (XMPPException e) {
  
System.out.println("PRIVACY_ERROR: " + e);
  
}
  
}

 

just call the above method here...

XMPPAddNewPrivacyList(XmppConnection.getInstance().getConnection(),
"91xxxxxxxxxx");

 

after call that above method i got a response like this

 

<iq id="5W6tl-27" type="set">
 
<query xmlns="jabber:iq:privacy">
  
<list name="newList">
  
<item action="deny" order="1" type="jid" value="91xxxxxxxxxx"/>
  
</list>
 
</query>
</iq>

<iq to="xyz@test-xmpp-abc/Smack" id="5W6tl-27" type="result">
 
<query xmlns="jabber:iq:privacy">
  
<list name="newList">
  
<item action="deny" order="1" type="jid" value="91xxxxxxxxxx"/>
  
</list>
 
</query>
</iq>

 

 

It's working successfully. I referred whatsapp,  we cannot able to send the message which  we blocked. as well as if they send the message , we are not receiving that message. But here, i can send and receive the message after i blocked that user. I don't know why if any one know please let me know.

Outcomes