What about an AsyncTask
with a reference to a static retained Fragment (without an UI) hosted in an Activity or another fragment ? No memory leaks, elegant async operations in a separate thread, no object reference losses.
I think this would be ok for http request, but not for file uploads / downloads. If you read carefuly, there is a sentence:
If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs provided by the java.util.concurrent pacakge such as Executor, ThreadPoolExecutor and FutureTask.
But they do not mention, that a service with a separate Thread could be a good option too. This is meant to continue executing the tasks in background, no matter what the user does. (d.g. if he uploads some file you do not want to stop this because he has left the activity)
This link for samples - find the RetainedFragment.java
This link for AsyncTask.