How to search for users with Smack 4.4?

I want to search user on server by those:

val userSearchManager = UserSearchManager(connection)

for (service in userSearchManager.searchServices) {

    if (BuildConfig.DEBUG) {

        Log.d(TAG, "search with service: $service")


    val searchForm = userSearchManager.getSearchForm(service)

    val answerForm = searchForm.createAnswerForm()

    answerForm.setAnswer("userAccount", true)

    answerForm.setAnswer("Username", "admin")

    val data = userSearchManager.getSearchResults(answerForm, service)

    if (data != null) {

        Log.i(TAG, data.toString())



It works in 4.3.0, But the method getSearchForm() was removed in 4.4.6, so waht should I do if I still use 4.4.6?

UserSearchManager.getSearchForm(DomainBareJid) still exists in 4.4.6? Am I misunderstanding your question?

It’s my fault…The method createAnswerForm() was removed.

For Smack 4.4

val searchDataForm = userSearchManager.getSearchForm(service)
val searchForm = new Form(searchDataForm)
val fillableSearchForm = searchForm.getFillableFrom()
... // fill out the form
val results = userSearchManager.getSearchResults(fillableSearchForm.getDataFormToSubmit(), service)

Hope that helps :slight_smile:

Many thanks :smiling_face_with_three_hearts:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.