AsyncTaskLoader with Dialogs, Is it feasible?
I started an new app and I wanted to use the latest patterns and guidelines for android, one of those is to use Loaders (AsyncTaskLoader) instead of AsyncTasks, I'm trying to see if Loaders are suposed to really replace all your AsyncTasks "tasks" i.e.
Let's say you want to build an app based on REST calls, one of those calls is in charge of login the user. So while you click submit (on a fragment button) a dialog comes up until the response gets back, if I'm correct the AsyncTaskLoader onLoadFinished won't let you dismiss a dialog unless you use a handler, and well using this, makes the solution look a bit hacky, cause then you need to show error dialogs like for when the username or password is wrong, and well you may end up with a bunch of calls to handlers.
I did this in a snap using an AsyncTask and all working ok, now that I was moving all the code to AsyncTaskLoader it seems I'm hacking many things when it's supposed to be easier, I'm a beginner so please be patient with your answers.
I appreciate the time you take.
I'm trying to see if Loaders are suposed to really replace all your AsyncTasks "tasks".
A Loader performs asynchronous loading of data, monitors the source of its data and delivers new results when the contents of its data changes. An AsyncTaskLoader is a Loader that uses an AsyncTask to offload the Loader's operation to a separate thread. An AsyncTask is basically Android's version of a Thread; it abstracts out the tedious multithreading details and provides a few convenient callback methods.
In your case, logging in the user is a one-time, potentially expensive REST request... it has nothing to do with loading/monitoring a data source. You should use an AsyncTask instead.