powered by Jive Software

How to listen for the IQ packet

android

#1
<iq from='localhost' to='*****@localhost/android' id='2627FFBDF2C581D9' type='get'><ping xmlns='urn:xmpp:ping'/></iq>

I want to listen for this type of IQ packet. i tried to listen for this using

xmpptcpConnection.addSyncStanzaListener(new StanzaListener() {
            @Override
            public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
                Log.e("PACKET", packet.toXML().toString());
            }
        }, new StanzaFilter() {
            @Override
            public boolean accept(Stanza stanza) {
                return stanza instanceof Ping;
            }
        });

but dont receive any packet in it.
I tried the same with IQ instead of Ping, i get all the iq packets but not the IQ packet which contains the Ping element as child.

and i also tried the AndFilter for the same, and that didn’t worked either
this is how i used the AndFilter

 StanzaFilter stanzaFilter = new AndFilter(StanzaTypeFilter.IQ, new StanzaTypeFilter(Ping.class));
 xmpptcpConnection.addSyncStanzaListener(new StanzaListener() {
            @Override
            public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
                Log.e("PACKET", packet.toXML().toString());
            }
        }, stanzaFilter);

but no luck