Is there a common way to consume web services from Android applications (aside from the protocol)? What I need is a Service or Intent or Thread (or anything else) that is capable of:
- staying alive no matter what Activities are open;
- be able to perform multiple requests at the same time;
- accept input values and return output values to the right caller;
- be able to discard an ongoing operation (while keeping to run all the others) and not to return the output value if it is no longer desired;
- (of course) run asynchronously.
Is there a common way to accomplish this? I’ve had some issues while using Services, primarily because I wasn’t able to discard an ongoing operation, so the results were colliding with each other.
mmm you need a combination of things here. First of all, you need a service layer implement it with a Bound Service (inherits). Your UI activities must call this service through an Intent.
Then, this layer that would be execute it in a different thread than your UI layer, must have a Rest Client object to perform services calls.
Here you have lot of approaches, I recommend you Spring Rest implementation as well as Restlet.
As is a pretty big discussion, anything else please tell me.