PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(GlobalVar.mConnection);
List<PrivacyItem> pList = privacyManager.getPrivacyList("BlockedUsers").getItems();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid, name+"@"+GlobalVar.mConnection.getServiceName(), false, 1);
item.setFilterMessage(true);
item.setFilterPresenceIn(false);
item.setFilterPresenceOut(true);
item.setFilterIQ(false);
pList.add(item);
privacyManager.updatePrivacyList("BlockedUsers", pList);
This works perfectly for adding a new user to the "BlockedUsers" list.
The issue is removing them.
int count =-1;
for(PrivacyItem e:pList){
count = count + 1;
//Looping through list removing item that has the same value as the user i want to unblock
if (e.getValue().equalsIgnoreCase(name+"@"+GlobalVar.mConnection.getServiceName()) ){
pList.remove(count);
//Update list with removed user
privacyManager.updatePrivacyList("BlockedUsers", pList);
}
}
I noticed that when I used spark to remove the same person it would just null-ify them.
tried to do something similar using e = null. Didn't work.
Also tried to just change the same item doing the following.
e.setFilter<All>(false);
seemed to add a new user to the list instead of updating the preexisting user.
Flow i require your expertise all mighty one! (You have helped me at least 30 times by answering other questions. I can not for the life of me find something similar to this in my google searches)
(Using asmack 4.0.4 snapshot)