I’m wondering if an Android Loader (more specifically AsyncTaskLoader) is the correct job for asynchronously submitting data to a web service.
The way I see it, most of the examples deal with grabbing data and displaying it to a user. For such operations things like having it “accidentally” hit the URL endpoint twice, or caching data is the norm.
However, when we’re dealing with submitting data we want a way to absolutely make sure that:
- the data is only submitted once
- the submit operation is done anew each time we call it
- we can pass a result back that will notify the user that the action was successful (or failed)
So, with that being said, how would I go about using the Loader pattern to send data in an asynchronous fashion? Are there any examples that exist for this type of use-case? Or is a Loader not the right thing, and I should be using something else altogether?
You are probably looking for
AsyncTask. The loader caches data internally and returns it to the app to be displayed by the app, it is not really designed to submit data. Why do you think you need to use aLoaderfor this?