GeoCap
GeoCap

Reputation: 515

Keep socket connection (TCP) when switching activity

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

Answers (1)

Muhammad Sabeel Ahmed
Muhammad Sabeel Ahmed

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

Related Questions