2

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.

Chetan Bhoyar
  • 501
  • 4
  • 12
  • I got solution to this problem just follow the answer http://stackoverflow.com/questions/5910219/problem-using-usersearch-in-xmpp-with-asmack like and set time out to 9000 mil.sec. – Chetan Bhoyar Aug 08 '12 at 05:32
  • Or You can simply add this line of code // Data Forms ProviderManager.getInstance().addExtensionProvider("x", "jabber:x:data", new DataFormProvider()); At first line of my code then it will also run. Thankx. – Chetan Bhoyar Aug 08 '12 at 05:52

0 Answers0