Connection closed when android app was killed from recent app list in Oreo

I have an Android app and used Smack for the chat integration. Now I am facing an issue in Android Oreo devices, that is the connection was closed whenever the app was killed from the recent app list. Therefore I didn’t get any messages from the server. I have implemented the foreground service also to keep the service in running state But it was also killed because of connection loss.

Smack Version. 4.2

Are you sure your XMPPConnection is held by your foreground-service?
You can take a look at MAXS for an example of how a service might hold a connection.

It is not really surprising that the connection is closed when the app is terminated.