I decided to start learning Android with writing monitoring/management application that reads data from server socket. So far so good, but I believe I could have made a design error. I created service, that connects to server socket, reads data and broadcast it to activities (TabActivity). The application works fine, I get my data updated, but now I want to add extra funcionality of sending data from my device to server. To do so, I need to send data to socket = send data to service (where I have my socket connection opened).
I believe that it could be wrong way to do it? I mean to get somehow service instance from activity?
My question now is:
1. Is it ok I used service to create and keep my socket connection to server? If yes, how can now send data to service? If no, what should I use in such scenario then?
Thanks in advance,
Joined: Mar 22, 2005
Activities communicate with Services through Intents (to which extra data can be attached). Only the Service would be concerned with what to do with that data. Is that what you're asking?
Ulf Dittmer wrote:Activities communicate with Services through Intents (to which extra data can be attached). Only the Service would be concerned with what to do with that data. Is that what you're asking?
Yes, I guess. I will try and get back with results. Thanks Ulf.
Joined: Mar 14, 2006
yes, I used the Intent, broadcasted it, Service received the command and I could send it through socket to my server.