我无法阻止用户,下面是我正在使用的代码
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.toString(), false, 2);
item.setFilterIQ(true);
item.setFilterMessage(true);
item.setFilterPresence_in(true);
item.setFilterPresence_out(true);
item.setValue(friendName);
item.setOrder(23);
privacyItems.add(item);
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(connection);
String privacyListName = MailManager.getAddress();
try {
//privacyManager.updatePrivacyList(friendName, privacyItems);
privacyManager.createPrivacyList(friendName, privacyItems);
} catch (Throwable e) {
}