1
在XMPP中,当我向其他用户发送好友请求时,如果其他用户想拒绝它,则应从名单中删除条目,但我无法删除条目来自用户。这是给我强制关闭(与空指针异常)在Xmpp中拒绝请求 - 从名单中删除条目
这里是我的拒绝按钮代码
btn_Deny = (Button)findViewById(R.id.btn_manageNotification_DENY);
btn_Deny.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Presence unsubscribe = new Presence(Presence.Type.unsubscribed);
unsubscribe.setTo(id);
connection.sendPacket(unsubscribe);
/*String message = mXmconn.removeFriend(subID, CMMStaticVariable.CommonConnection);
System.out.println(message);*/
Intent returnBack = new Intent(ManageNotification.this, UserMenuActivity.class);
startActivity(returnBack);
finish();
}
});
}
删除好友
public String removeFriend(String jid, XMPPConnection connection){
roster = connection.getRoster();
String message = "";
try {
RosterEntry rosterEntry = roster.getEntry("[email protected]");
System.out.println("rosterEntryy"+rosterEntry.toString());
roster.removeEntry(rosterEntry);
message = "You have denied the friend request";
} catch (XMPPException e) {
e.printStackTrace();
message = "Exception";
}
return message;
}
它在rosterEntry = null被赋予空指针;
感谢
但没有状态的名单项目根本没有删除,而是它在RosterEntry给我空指针异常。 谢谢 – 2013-03-06 09:42:58