I am in quite a dilemma about how to solve my problem regarding network access. I checked this question but it does not really gives a solution for my problem.

All of my REST based requests are routed through my own HttpRequestExecutor class that will execute each request asynchronously and results will be sent back via handler passed to it per request.

Some of these requests are originating from UI and needs to end there as well for example Sign in request. In most cases user has to wait till it finishes. I would like to write some high level and specialized class for each of such use case as it may do some business level processing before and/or after request is executed. The result will be handed down to the originating Activity.

This could be done either using a Service or simple Java class both using thread. I am not sure which way to go.

A simple Java class would be straight forward and simple solution but I feel Service may be the correct way to do it. What I am really concerned about using Service is the boiler plate code that goes into using it i.e. binder or messaging to communicate with Activity.

For this problem which is the correct way to solve? Also does Service provide some extra advantages in this case?


1 Answer 1


Your question is similar to: Android Design - Service vs Thread for Networking. I have been looking for some guidance on this, and I'm drawing some points from the accepted answer there.

Put in the work for the Service. It de-couples the functionality from the UI and can be used in future Apps. Use your simple Java class as the internals. The interface of a Service makes the code more easily re-usable and more easily extensible.

Not the answer you're looking for? Browse other questions tagged or ask your own question.