Volley or Service with cursor loader

前端 未结 5 483
天命终不由人
天命终不由人 2021-02-01 09:49

I almost always use a Service when I download data from a web service. I store the result in a database and displays the result in my view using a cursor loader. But after Googl

5条回答
  •  孤街浪徒
    2021-02-01 10:05

    Volley is meant to provide a more convenient way to asynchronously perform network requests. It doesn't require you to subclass a Service or an AsyncTask, and its syntax is very straight forward for any experienced developer.

    As stated above, this is entirely a convenience. If you have a mechanism that works well, then by all means use it. If you find yourself rewriting code constantly that follows your existing model, you may want to look into a reusable library, such as Volley or droidQuery.

    There is no right or wrong answer. There may, however, be a better or worse factor. The main comparison here is speed. Volley boasts fast speeds, and plans to support OKHTTP soon, as well as to become part of the Android SDK (or a compatibility pack), continuing to grow with the Android platform. If these things are important to you, then maybe you should switch for future applications (unless you have noticeable lag in current applications, I would struggle to see a point to changing working code).

提交回复
热议问题