我想使用XMPP阻止聊天列表中的特定朋友。我这样做的代码:
public void blockUser(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);
privacyManager = PrivacyListManager.getInstanceFor(mXMPPConnection);
try
{
privacyManager.createPrivacyList(listName,privacyItems);
}
catch(Exception e)
{
Log.e("PRIVACY_ERROR: "," "+e.toString());
e.printStackTrace();
}
}
代码工作正常。没有例外,但我无法阻止用户。任何人都可以帮助我吗?
Smack Logs我得到了:
<main><iq type="set" id="373-3717" to="nitstest1@hostname/smack"><query xmlns="jabber:iq:privacy"><list name="newList"/></query></iq>
09-04 19:00:38.368: D/SMACK(3895): 07:00:38 PM SENT (1149259528): <iq id="373-3717" type="result"></iq>
09-04 19:00:38.658: D/SMACK(3895): 07:00:38 PM RCV (1149259528): <iq type="result" id="LvJcf-9" to="nitstest1@hostname/smack"><query xmlns="jabber:iq:privacy"><list name="newList"><item action="deny" order="1" type="jid" value="nitsquytech@hostname"/></list></query></iq></main>
答案 0 :(得分:1)
您需要将您创建的隐私列表设置为活动列表。