Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the Volley network request queue?

I .add( new network calls to my Volley Request Queue which I have created as a singleton as suggested. But I always immediately .start() these network calls. This is always done as an action in an activity or a fragment.

The add method cannot even be chained into a start method, like .add(new volley request).start()

So this assumes I am actually managing (or wanting to manage) a network queue somewhere, outside of the way Volley handles its queue, I guess. Should I be sending these things to an IntentService and listening for the IntentService to send a response back to my Fragment/Activity?

like image 457
CQM Avatar asked Feb 28 '14 21:02

CQM


People also ask

What is request queue in volley?

requestQueue is used to stack your request and handles your cache. You need to create this RequestQueue in your application class or in a Singleton class. Then only you can use the same requestQueue from multiple activities.

What is the use of RequestQueue?

RequestQueue is where all the requests are queued up that has to be executed, it also manages the worker threads and maintain network call in the background also it handles reading from and writing to the cache and also parsing the response and delivering the parsed response to mainthread.

How does volley work?

Volley automatically schedules all network requests such as fetching responses for image from web. Volley provides transparent disk and memory caching. Volley provides powerful cancellation request API for canceling a single request or you can set blocks of requests to cancel.

How do I create a request queue?

requestQueue = new RequestQueue(cache, network); // Start the queue requestQueue. start(); String url = "http://www.example.com"; // Formulate the request and handle the response. StringRequest stringRequest = new StringRequest(Request.


1 Answers

As a volley user I can tell you that I have never called .start() method. all the requests i've added to the queue started automatically, I used singleton class like you did.

like image 103
Udi Oshi Avatar answered Sep 20 '22 17:09

Udi Oshi