how we can end the session of praticular user in X

2019-06-01 07:36发布

问题:

Button logout = (Button) this.findViewById(R.id.btlogout); logout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            connection.disconnect();
            setContentView(R.layout.login);


        }
    });

this code is allowing me logout but not killing the session and the page which i am redirecting that page's button is not working .

回答1:

First of all send presence packet to server and then you should logout. This way your session will be killed.

Presence pr=new Presence(Presence.Type.unavailable);
connection.sendPacket(pr);
connection.disconnect();

it will first made you offline and then after disconnect from server.Hope it will help.Thanks.



标签: android xmpp