如何使用aSmack库从本地Openfire服务器搜索用户详细信息?

时间:2013-07-17 05:59:38

标签: android xmpp smack asmack

我正在开发聊天应用程序,其中我正在使用openfire服务器和asmack库。我想搜索在该服务器上注册的用户。

这是我写的代码..

    UserSearchManager search = new UserSearchManager(connection);  
            try {
                Log.d("JWP", "cc:"+connection.getServiceName());
                org.jivesoftware.smackx.Form searchForm = search.getSearchForm("search."+connection.getServiceName());
                org.jivesoftware.smackx.Form answerForm = searchForm.createAnswerForm();  
                answerForm.setAnswer("Username", true);  
                answerForm.setAnswer("search", editTextSearch.getText().toString());  
                org.jivesoftware.smackx.ReportedData data;
                data = search.getSearchResults(answerForm,"search."+connection.getServiceName());
                if(data.getRows() != null){   
                    Iterator<org.jivesoftware.smackx.ReportedData.Row> it = data.getRows();
                    while(it.hasNext()){
                        org.jivesoftware.smackx.ReportedData.Row row = it.next();
                        Iterator iterator = row.getValues("jid");
                        if(iterator.hasNext()){
                            String value = iterator.next().toString();
                            Log.i("Iteartor values......"," "+value);
                        }
                    }
                    Toast.makeText(Welcome.this,"Username Exists",Toast.LENGTH_SHORT).show();
                }
            }
            catch (XMPPException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

但是这里getSerachFrom()方法返回null值,尝试过各种各样的东西,但不明白为什么会这样。 我的openfire服务器拥有多个注册用户。

0 个答案:

没有答案