Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley or ASyncTaskLoader

They tell everywhere that we should use ASyncTaskLoaders because they are very good at not blocking the UI thread. And there is Volley to use now.

I guess we cannot use both of them because Volley does backgrounding on its own. What do you think? Which one is better?

like image 871
tasomaniac Avatar asked Jul 29 '13 10:07

tasomaniac


4 Answers

These 2 technologies are different and hardly comparable. They have different purposes and can also work together. You could for exemple implement a Loader that uses Volley to load the data and inherits directly from Loader (not AsyncTaskLoader, because Volley handles the threading as well).

Main advantages of using Loaders:

  • Lifecycle is synchronized with the Activity/Fragment lifecycle automatically
  • Data and loading state is not lost on configuration change
  • The loader monitors changes and pushes new results automatically to the client fragment/activity.

Main advantages of using Volley:

  • High performance network stack
  • Automatic disk cache that respects the HTTP server policy
  • Powerful cancelation mechanism.

You can combine both to get both sets of advantages or you can use Volley without loaders with its simple API.

like image 65
BladeCoder Avatar answered Nov 09 '22 05:11

BladeCoder


I've been using Volley for a month now and I have to say that I'm very satisfied. It really does help a lot not to have to worry about threading implementation details. So far both general networking and remote image loading have been working great.

It's not that there are no issues, but so far they have been minimal.

like image 29
Itai Hanski Avatar answered Nov 09 '22 05:11

Itai Hanski


You better ask like this volley vs Async vs RxJava

You can use this RXJava for background thread, but for better efficiency in calling restful services Volley is highly recommended, also very less coding required compare to async task loaders !

like image 1
LOG_TAG Avatar answered Nov 09 '22 05:11

LOG_TAG


Here is a writeup on current Android best practices. It discusses the use of Volley and RXJava: https://github.com/futurice/android-best-practices

like image 1
IgorGanapolsky Avatar answered Nov 09 '22 03:11

IgorGanapolsky