I have gone through this1, this2 and this3 but still cannot find the solution of the problem.
I could know where my problem is what I am doing in this code is:
Try this. It solves my problem.
UserSearchManager search = new UserSearchManager(mXMPPConnection);
Form searchForm = search.getSearchForm("search."+mXMPPConnection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", user);
org.jivesoftware.smackx.ReportedData data = search.getSearchResults(answerForm,"search."+mXMPPConnection.getServiceName());
if(data.getRows() != null)
{
Iterator it = data.getRows();
while(it.hasNext())
{
Row row = it.next();
Iterator iterator = row.getValues("jid");
if(iterator.hasNext())
{
String value = iterator.next().toString();
Log.i("Iteartor values......"," "+value);
}
//Log.i("Iteartor values......"," "+value);
}
Toast.makeText(_service,"Username Exists",Toast.LENGTH_SHORT).show();
);
}
If Server has not any entery with that specified name then Itearator it has no value and code will not go inside while(it.hasNext).