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?
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?