0
votes

I implement an IM app on Android use asmack library.

In code, I use a singleton object to manage the XMPPConnection instance, then I build the connection after main Activity launched.

But when I press the back button to exit my app, then I found my XMPP account be offline after some minutes.

How can I keep-alive the xmpp on background?

1
you could load that singleton in a serviceA.S.

1 Answers

0
votes

You should be using startForeground() in your service, particularly if you plan on keeping the service running when your chat client activity is not necessarily in the foreground.
or make one service which send presence to server in regular interval in connection is live and your app is go in back ground.