AnsweredAssumed Answered

smack 4.2 roster object gets loaded even before RosterLoadedListener is added

Question asked by Sarthak Mittal on Mar 15, 2017
Latest reply on Mar 16, 2017 by Flow

After authenticating my XMPPTCPConnection. I am trying to create a Roster Object :

 

val roster = Roster.getInstanceFor(connectionObject)

// sometimes roster is already loaded even before adding a listener.

if (!roster.isLoaded) {

  roster.addRosterLoadedListener(object : RosterLoadedListener {

   override fun onRosterLoaded(roster: Roster?) {

   // Do Something

   })

  }

   override fun onRosterLoadingFailed(exception: Exception?) {

  }

  })

} else {

// Do Something

}


Is there a more clear way to achieve this?

Thanks.

Outcomes