Play with this demo
In this Activity, you can :
- start a Loader and observe Loader's progress ;
- cancel a started Loader ;
- start a Loader, rotate the device and observe that UI is updated as expected (no need to wait for the loader to fully completes);
- after you rotated the device, the loader is still complete : starting it again will get you instantly with the
result (full progress) and you must cancel the loader to restart it.
- rotate the device as much as you want, we implemented a workaround to the "limitation of 1 rotation bug" observed in the previous example;
- observe no more memory leak, you can start as many Loaders as you want.
Loader with progress.
This Activity uses a simple Loader but adds support to get Loader progress.
Progress and loaders
On this demo activity, you can observe the progress of the Loader's job. This hack is practical but not so clean.
It has been supplied by the community as a workaround to loader limitations on Stack OverFlow Update progressbar from AsyncTaskLoader ?.
We should remember why loaders have been designed : optimizing data base access. This operation has no interest in the "progress information".
Using them for other purposes is simply using the wrong tool to achieve it.
Next Activity provides an example of Loader usage to perform a REST request, we will demonstrate why Loaders don't fit when it comes to networking.