I want to search the user from server.
I write the following code as I got from searching.
pm.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
UserSearchManager search = new UserSearchManager(connection);
Form searchForm = search.getSearchForm("search."+connection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
Toast.makeText(this,username.getText().toString(),Toast.LENGTH_SHORT).show();
answerForm.setAnswer("search", username.getText().toString());
ReportedData data = search.getSearchResults(answerForm,"search."+connection.getServiceName());
if(data.getRows() != null)
{
Toast.makeText(this,"Username Exists",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this,"Username Available",Toast.LENGTH_SHORT).show();
}
But it throws class cast exception on
Form searchForm = search.getSearchForm("search."+connection.getServiceName());
on this line.
I have already download the source code of asmack-android-5.jar lib, gone through it, Debug it. I Found exception on this line
// Check if the existing DataForm is not a result of a search
DataForm dataForm = (DataForm) packetExtension;
of class org.jivesoftware.smackx.Form in side the source code.
I tried it many time, but not get solved this problem.
Thanks in advance.