Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design error in my app?

 
Michal Glowacki
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michal Glowacki
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I used the Intent, broadcasted it, Service received the command and I could send it through socket to my server.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic