E
E
Eugene2017-04-17 19:45:27
Java
Eugene, 2017-04-17 19:45:27

How to interact with socket in android?

Good day. I am developing an android application that will communicate with the server via sockets. And the question arose: how to properly store the socket object? Does it need to be recreated on every request, or only opened when the application starts? Then how to access it from anywhere in the application? Through a singleton? But then how to do it with parameters? There are more questions than answers. Maybe someone faced this in their applications?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
danil_chistov, 2017-04-17
@danil_chistov

You can use a Service that will create an instance of the socket class and work in the background, and you can get a service from other classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question