I have a main activity that launches:
1.- A network prone thread that writes into a socket.
2.- A network prone service that is supposed to read from a socket.
So far I’m done with 1. but I want the information read from the socket to be shown in the main activity. I know I can pass information between the activity and the service using extras but how can I tell the activity to update and get the new data?
I have a main activity that launches: 1.- A network prone thread that writes
Share
I guess that you could use broadcasting intents combined with a BroadcastReceiver in your main activity in order to achieve background communication.
Here’s a snippet that can achieve this.
(CODE PUT IN THE ACTIVITY):
Then, in your service, you simply broadcast an intent (with whatever extras you need)… Say with something like this: