1
votes

I am using smack API to connect to Openfire server. Am able to create user, login and exchange message. After logout I want my activity to be finished( user has to come to home screen) without disconnecting with the server.
Any one have used Smack API for this kind of scenario?

2

2 Answers

3
votes

If you are using smack on Android then you should consider running the connectivity part of your application as a service which can be flexible and run in the background. You will be disconnected from the server if your activity goes to the onStop() or onDestroy() state.

Logging out can be done by YourConnection.disconnect. If you don't want to disconnect from the server you will have to change your presence instead.

0
votes

I not found any solutions in the Smack documentation. If you make connect(), after disconnect() you will be authinticated again, and login throw AlreadyAuthanticated exception.

But, after disconnect, you can destroy XMPPConnection obect and create new one.