• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Packetlistener problem in XMPPConnection

manvinder

Newbie
Hi all

I m using smack api for my Chat application. i am using following code segment to listen incomming message update the ListView to show those message....

PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
mConnection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom());

//Code for updating mConversationArrayAdapter to populate ListView

mHandler.post(new Runnable() {
public void run() {

mConversationArrayAdapter.notifyDataSetChanged();
}
});
}
}
}, filter);


the problem is that when the activity is loaded first time the code works fine but when the activity is resumed again the incomming messages are listed twice. where is this problem in the code?
 
Back
Top Bottom