Volley or ASyncTaskLoader
Asked Answered
S

5

6

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?

Stent answered 29/7, 2013 at 10:15 Comment(5)
check out this both have different benefits you have to find yours.Oxa
The link compares Volley with ASyncTask. Volley is way better then AsyncTask. That is known. But what about the Loader interface? We cannot use Loader interface if we use Volley, can we?Stent
in upper url check kpbird tutorial they have show progress dialog.Oxa
Not related at all. It is just a basic tutotialStent
I think Volley is better for static content loading. But for long live download operation(like large file or streaming ), it's better to use Ansync Task since you could control all the stuff like locking, I/O, etc. You could watch the video in Google I/O 2013. There's a little comparison in the first couple of mins of the lecture .Barometrograph
M
3

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.

Mortify answered 22/4, 2014 at 19:35 Comment(0)
N
2

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.

Nissy answered 2/9, 2013 at 14:29 Comment(0)
C
1

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 !

Coadunate answered 3/9, 2013 at 7:49 Comment(3)
Less coding aspect of Volley is very appealing. Thank you.Stent
But Volley does not have actor/subscriber model that RXJava has. Right?Seismic
@Seismic There is no Rx Volley implementation available yet I guess !! However you can try the Rx implementation with Retrofit !! github.com/vyshane/rex-weatherCoadunate
S
1

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

Seismic answered 13/2, 2015 at 22:26 Comment(0)
T
0

You can combine both, to get both advantages.

In your activity (main thread) you call your API with Volley. With a simple interface mechanism, you callback your main thread when the data is available. Then you forceLoad() your AsyncTaskLoader with the fresh data from Volley. In your AsyncTaskLoader you hydrate all your activity's container. They will be automatically loaded when data is available.

With this approch you combine Automatic disk cache of Volley, and Automatic synchronization of Loader.

Thrombin answered 10/5, 2020 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.