使用Volley类创建RequestCache时如何设置RequestQueue缓存?

时间:2016-06-09 06:59:39

标签: android-volley

我正在单例类中创建一个RequestQueue,而Google提供的示例是通过调用Volley类的newRequestQueue来创建它,该类作为参数只是当前应用程序的Context:

mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());

以前我没有使用单例类,我使用以下代码在活动OnCreate中创建了一个RequestQueue:

Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap

// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());

// Instantiate the RequestQueue with the cache and network.
mRequestQueue = new RequestQueue(cache, network);

因为使用此代码我设置网络和缓存我搜索适当的newRequestQueue方法的Volley类但我注意到newRequestQueue只有两个重载,一个带有我可以用来设置网络的HttpStack参数,但是没有Cache参数。

所以问题是:有一种方法可以创建一个使用Volley类对其缓存进行成本化的RequestQueue吗?

0 个答案:

没有答案