I am developing an android chat application using openfire smack library.I have created a bound service to listen to messages when the is in background.The connection object is also maintained by service.Service is working fine as listening to background messages,but the problem is user is shown online all the time when the app is in background.Keeping the connection is also necessary so that user can listen to messages but this connection is showing user online all the time.I want to show user offline when app is in background.One thing more i am a beginner in android application as well as in xmpp protocol.If you think my question senseless plz don't vote down it because for a beginner every question has sense
To show that user is offline, you need to send presence as unavailable to server so that it is published to your roster entries. Now you should be shown as offline to other users but your session exists so Openfire will route your messages to you. Now on application coming to foreground, you can send again your presence indicating you are available.