Answer the question
In order to leave comments, you need to log in
Where is the best place to keep WebSocket?
The application works in an isolated network, there are no notifications, but there must always be a connection with the server.
Foreground service. There is a library that outputs all events from the websocket to the listener.
Obviously, this listener should work in the background, there will be parsing of packets and their transfer to the UI.
For now, I'm thinking of just wrapping the socket and listener in a normal Thread, and keep the Thread itself in the service.
through binding to the service to manage the socket (send, stop, reconnect, etc.)
Answer the question
In order to leave comments, you need to log in
Yes, you can do that. But a normal service will be killed fairly quickly. What is needed is the foreground.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question