0
votes

I am new to XMPP protocol, i tried to find good examples of sending and receiving IQ packets in XMPP ANDROID, but i failed, I tried using the following chunk of code but it did not help.

CODE:

final IQ iq = new IQ() {
    public String getChildElementXML() { 
    return "<iq type='get' from='[email protected]/9f30dacb' id='1'> <query xmlns='http://jabber.org/protocol/disco#info'/></iq>"; // here is your query
    //"<iq type='get' from='[email protected]/9f30dacb' id='1'> <query xmlns='http://jabber.org/protocol/disco#info'/></iq>";
     }};
    // set the type
iq.setType(IQ.Type.GET);
// send the request
connection.sendPacket(iq);

I tried using this code, but it did not send any message to server. can somebody help me with right piece of code? so that i can send my IQ's to the server and receive the response

2

2 Answers

1
votes

Haven't tested it yet, but try

    IQ iq = new IQ();
    iq.setTo("destination@server");
    iq.setFrom("[email protected]/9f30dacb");
    iq.setType(IQ.Type.GET);        
    iq.setPacketID("1");
    connection.sendPacket(iq);
0
votes

I think you should use the correct address of destination, that includes the resource from destination, like this example

iq.setTo("destination@dominio_destination.com/recurso_destination");

Now you can send the packet:

connection.sendPacket(iq);