0

In my application there is a requirement. I want to get the presence and mode of the login user itself how can i get that???

 Roster roster = connection.getRoster();
    Presence checkPresence = roster.getPresence(useritself);

When I use this code to get the presence of the login user it always gives me unavailable.

How can I get the presence of login user itself by this means or any other means

Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143

1 Answers1

2

Is useritself a bare (localpart@domainpart) JID? Is useritself logged in on a different device? If not, depending on the server, you may not receive presence from yourself. Also, make sure that you're not doing this presence check until after you've received all of the presence. The best way to achieve this is to register a callback for presence changes, rather than querying for the current presence state.

Joe Hildebrand
  • 10,354
  • 2
  • 38
  • 48
  • Thanks for the reply. Actually I am maintaining a scenario for which I receive notification when I am not on a particular screen. Now If a am on that particular screen I should not receive notications. For that purpose I want to check presence if i am on that screen or not? – Gaurav Arora Oct 22 '12 at 04:04