In my chat application. I am using Smack library and Openfire server. I want to block particular user.
I am trying to implement a function which will block a particular user but its not work for me.and it will not give any error or exception.
My code is
public void XMPPAddNewPrivacyList(XMPPConnection connection, String userName) {
String listName = "newList";
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.toString(),
false, 1);
item.setValue(userName);
privacyItems.add(item);
// Create the new list.
try {
PrivacyListManager privacyManager = new PrivacyListManager(connection);
privacyManager = PrivacyListManager
.getInstanceFor(connection);
privacyManager.createPrivacyList(listName, privacyItems);
} catch (XMPPException e) {
System.out.println("PRIVACY_ERROR: " + e);
}
}
XMPPAddNewPrivacyList(XmppConnection.getInstance().getConnection(),
"91xxxxxxxxxx@xxx.com");