powered by Jive Software

I am not able to get online user from xmpp server using smack 4.2

Hello,

I have set up ejabberd 16.09. I am using smack 4.2. I am not able to get online user from xmpp server . so please provide me solution as soon as possible.

I have set below dependecies -

compile "org.igniterealtime.smack:smack-android-extensions:4.2.0"
compile "org.igniterealtime.smack:smack-experimental:4.2.0"
compile "org.igniterealtime.smack:smack-tcp:4.2.0"
compile “org.igniterealtime.smack:smack-android:4.2.0”

tried below code after login -

Presence p = new Presence(available, “I am busy”, 42, Presence.Mode.dnd);

MyXMPP.connection.sendStanza§;

and then check for online user -

roster = Roster.getInstanceFor(MyXMPP.connection);

try {

Presence userFromServer = roster.getPresence(JidCreate.bareFrom(“user”));

boolean isAvailable;

Presence.Type type=userFromServer.getType();

if (userFromServer.isAvailable()){

txtUser.setText(“Online”);

}else {

txtUser.setText(“Offline”);

}

I have used this code. but always get type unavilable and get false value for isavilable