if(searchstring.isEmpty())
{
XmppQuery iq = session.getFactory().createQuery();
iq.setIQ(service+"/users", XmppQuery.TYPE_GET, TextUtils.genUniqueId());
iq.setQuery("jabber:iq:browse");
session.send(iq,new XmppPacketListener()
{
public void onPacketReceived(XmppPacket packet)
{
onSearchResult(packet);
}
public void onPacketSent(XmppPacket packet)
{
}
});
}
else
{
XmppQuery iq = session.getFactory().createQuery();
iq.setIQ(service, XmppQuery.TYPE_SET, TextUtils.genUniqueId());
Element query = iq.setQuery("jabber:iq:search");
XmlDocument xmlDoc = XmlDocument.create("body", "foo");
xmlDoc.loadXML("<body>"+searchstring+"</body>");
query.appendChild(xmlDoc.documentElement().getFirstChildElement().cloneNode(true));
session.send(iq, new XmppPacketListener()
{
public void onPacketReceived(XmppPacket packet)
{
onSearchResult(packet);
}