AnsweredAssumed Answered

Getting all the users from openfire server using smack in android

Question asked by dhaval on Apr 7, 2016

i have a openfire server running on my localhost and i am successfully able to send and receive messages to registered users. however i am not been able to get all users from server. i am logged in with user that doesn't have a administration access. so do i need to give any permission on server side?

The code i am using for getting all users is..

 

if ( xmpp.getConnection()== null || !xmpp.getConnection().isConnected())
  
return;

  
try {
  
UserSearchManager usm = new UserSearchManager(xmpp.getConnection());
  
Form searchForm = usm.getSearchForm("search." + xmpp.getConnection().getServiceName());
  
Form answerForm = searchForm.createAnswerForm();
  
UserSearch userSearch = new UserSearch();
  answerForm
.setAnswer("Username", true);
  answerForm
.setAnswer("search", userName);
  
ReportedData data = userSearch.sendSearchForm(xmpp.getConnection(), answerForm, "search." + xmpp.getConnection().getServiceName());

  
for (ReportedData.Row row : data.getRows())
  
{
  arrayList
.add(row.getValues("Username").toString());
  
}
  
} catch (Exception e) {
  e
.printStackTrace();
  
}

 

i tried some solutions that shows to use Roster class, however that is also not helping me. Can anyone show what i am doing wrong or if i need to give any permission as i am not logged in as admin?

Thanks

Outcomes