• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design error in my app?

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic