Android 拒绝Xmpp中的请求-从名册中删除条目

Android 拒绝Xmpp中的请求-从名册中删除条目,android,xmpp,Android,Xmpp,在XMPP中,当我向其他用户发送好友请求时,如果其他用户想要拒绝,则应该删除花名册中的条目,但我无法从用户中删除该条目。它给了我强制关闭(空指针异常) 这是我的拒绝按钮代码 btn_Deny = (Button)findViewById(R.id.btn_manageNotification_DENY); btn_Deny.setOnClickListener(new View.OnClickListener() { @Override

在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("chamak@abec.info.com");
            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处给出null指针


感谢

XMPP-CORE定义服务器必须在拒绝订阅请求时从用户名册中删除名册项目。因此,当您试图请求该项目时,该项目甚至不应该在那里

根据规范:

注意:如果联系人的服务器先前出于跟踪目的将用户添加到联系人的花名册中,则此时必须删除相关项目


您可以阅读更多信息。

XMPP-CORE定义了服务器必须在拒绝订阅请求时从用户的花名册中删除花名册项目。因此,当您试图请求该项目时,该项目甚至不应该在那里

根据规范:

注意:如果联系人的服务器先前出于跟踪目的将用户添加到联系人的花名册中,则此时必须删除相关项目


您可以阅读更多信息。

但状态为“无”的花名册项目根本没有删除,而是在花名册中给我空指针异常。谢谢,但状态为none的花名册项根本没有被删除,而是在花名册中给了我空指针异常。谢谢