3

can any one explain why requestQueue are used in volley. and i also understood that all successful request are added to requestQueue (correct me if i am wrong). but why do we need to add successful request to requestQueue

vijay surya
  • 135
  • 1
  • 6

1 Answers1

6

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.

you create a requestQueue as follows,

 private static RequestQueue mRequestQueue;

 public RequestQueue getRequestQueue()
 {
    if (mRequestQueue == null) {
        Cache cache = new DiskBasedCache(MTXApplication.getAppContext().getCacheDir(), 20 * 1024 * 1024);
        Network network = new BasicNetwork(new HurlStack());
        mRequestQueue = new RequestQueue(cache, network);
        mRequestQueue.start();
    }
    return mRequestQueue;

}

for further details : RequestQueue

jaison fernando
  • 103
  • 1
  • 5