Reputation: 515
In the first activity I enter IP and port which connects the client to the server and a new activity opens. Is there an “easy” way to keep the connection alive using Kotlin?
Upvotes: 0
Views: 382
Reputation: 473
By using service you can achieve this, move all your network connection code into service, for all activities that want to use socket connection, bind your network service in onCreate()
then after finish unbind it in onDestory()
Upvotes: 1