I am kind of desperate. I am working on an application that is supposed to visualize pollution data. The application connects to the sensor via WiFi direct, the sensor is the group host. Then I am supposed to connect to port 5001 and retrieve data every 2 minutes. This data is supposed to be sent to a google maps activity where it will be visualized in an infowindow.
At this moment I have only been able to create a TCP connection that closes down immediately, I followed this Really simple TCP client.
So I need to establish a TCP connection that does not close and also runs when I am in other activities. I do not need to send any messages, only retrieve data.
I looked into this How to keep the android client connected to the server even on activity changes and send data to server? but did not understand how I am to implement that code for my case.
How do you do this? Appreciate any help.