I developed a chat app using Smack by XMPP server(openFire). For getting incoming message, i used to PacketFilter This is incoming msg code:-
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
incomemsg = message.getBody();
if (incomemsg != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom());
frmname = message.getBody();
Log.i("XMPPClient", "Got text [" + message.getBody() + "] from [" + fromName + "]");
// Add the incoming message to the list view
mHandler.post(new Runnable() {
public void run() {
// show the msg of chat in right side.
showMessage(frmname,false);
scrollContainer.getFocusables(scrollContainer.getChildCount());
}
});
}
}
}, filter);
But i want to remove paketListener during activity close or stop or destroy. i follow this http://community.igniterealtime.org/thread/28921 for remove packet listeners But not found solution.
please check. thank you for your timing.
Connection.removePacketListener
?