1. Download our Official Android App: Forums for Android!

Apps Packetlistener problem in XMPPConnection

Discussion in 'Android Development' started by manvinder, Jul 25, 2011.

  1. manvinder

    manvinder Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    May 9, 2011

    May 9, 2011
    27
    1
    16
    Software Developer
    New Delhi
    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?
     

    Advertisement

Share This Page

Loading...