I want to block a particular friend from my chat list with XMPP
. code works fine. There is no Exception, but I am not able to block a user.
I\'m using open fire ser
// Here function for block user on xmpp
public boolean blockUser(String userName) {
String jid = userName@localhost
String listName = "public";
// Create the list of PrivacyItem that will allow or
// deny some privacy aspect
//ArrayList privacyItems = new ArrayList();
List privacyItems = new Vector();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid, jid, false, 1);
// item.setValue(userName);
item.setFilterIQ(false);
item.setFilterMessage(false);
item.setFilterPresenceIn(false);
item.setFilterPresenceOut(false);
privacyItems.add(item);
// Get the privacy manager for the current connection.
// Create the new list.
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(XMPPUtils.INSTANCE.connection);
try {
privacyManager.updatePrivacyList(listName, privacyItems);
privacyManager.setActiveListName(listName);
return true;
} catch (Exception e) {
Log.e("PRIVACY_ERROR: ", " " + e.toString());
e.printStackTrace();
}
return false;
}