aspose file tools*
The moose likes Android and the fly likes Design error in my app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Design error in my app?" Watch "Design error in my app?" New topic
Author

Design error in my app?

Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
hi,

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,
Michal
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41477
    
  51
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?


Ping & DNS - my free Android networking tools app
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
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.
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
yes, I used the Intent, broadcasted it, Service received the command and I could send it through socket to my server.

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design error in my app?