Architectural question

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Architectural question

Postby DragonFlyJones » Fri Oct 08, 2010 2:56 pm

I'm new to Android and I'm porting an iPhone app I did. I've been reading up on Android services and they look very useful for the network component of my app. I assume there is a common pattern for what I'm trying to do, so here are the details:

1. User1 and User2 agree to enter a virtual room.
2. They send messages to each other and get notified when they receive a messages.

I'm using a remote server to handle the communication. So basically, I need three methods. One to add the users to a room, one to send messages and one to get messages. Nothing special.

What I'd like to do is have one service that accepts a few paramaters. One being which web service method to call, the rest being the parameters that need to be passed to the respective web services. I'd prefer this approach to having a different service for each method call. Any suggestions on the best approach? I'm not clear on how to pass parameters to services.
DragonFlyJones
Freshman
Freshman
 
Posts: 3
Joined: Thu Sep 30, 2010 4:57 am

Top

Re: Architectural question

Postby blundell » Sun Oct 10, 2010 10:38 am

Does it have to be a service? Surely you could just do this in a background thread, if it only needs to be done while the app is open?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Architectural question

Postby DragonFlyJones » Sun Oct 10, 2010 4:01 pm

No, it doesn't have to be a service but from what I've read about services that seems to be the cleanest way to go. The service will spawn a background thread though.
DragonFlyJones
Freshman
Freshman
 
Posts: 3
Joined: Thu Sep 30, 2010 4:57 am

Re: Architectural question

Postby blundell » Sun Oct 10, 2010 4:08 pm

I would recommend to make your own class that is a background thread, You can then use normal Java method's to get at and send your data. Also you don't have to worry about closing the service when your app goes into a paused state, or a user complaining that your "background service" is hoggin there battery :-). It's more inline with what your want to do and the google docs agree :-)
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests