powered by Jive Software

Subscribed to the user''s presence updates

I am confused as to how this works…

I am getting “null” returns from Roster#getPresence(ID), even when the user is online. How do I subscribed to the user’'s presence?

Do I need to setup a Presence Packet Listener? If so, an example would be nice.

Thanks.

are you sure the presence you are looking for is “available”, because if the presence is unavailable, if you are not subscribed to the presence, or if it just isn’'t in your roster, you will get returned a null value. If you could provide a little more information, like code, or when/how/who/what you are attempting to get the presence of it would be helpful. If you have the smack debugger up its easy to go in and see if someone is in your roster. Just flip through the IQ Recieved until you find your roster, then see if they are in there.

It’'s interesting, when I try and get the presence from say UserA using Roster#getPresence(), null is returned but the user is online.

I added a RosterListener which receives a change in presence right away from UserA which is available.

So basically, I get null from Roster#getPresence(), but my next lines of code is the RosterListener which provides available for UserA.

If that makes any sense…

The workaround seems to work for now…Thanks

are you providing their fully qualified jabber ID… like UserA@server.com? You need to make sure you are or otherwise getPresence won’'t work. The same String you get in #presenceChanged() should work for Roster#getPresence().