我有一个ID列表,我想获取该列表中每个ID的数据。是否可以使用volley或任何其他网络库,而不必在列表循环时调用请求,以节省执行时间?
发布于 2018-02-26 15:33:04
这就是我到目前为止所做的工作。要发送每个ID的多个网络请求,需要一个新的RequestQueue构造函数(用于volley)。` RequestQueue mRequestQueue = Volley.newRequestQueue(mContext);
// Instantiate the cache
Cache cache = new DiskBasedCache(mContext.getCacheDir(), 1024 * 1024); // 1MB cap
// Set up the network to use HttpURLConnection as the HTTP client.
BasicNetwork network = new BasicNetwork(new HurlStack());
mRequestQueue = new RequestQueue(cache, network, 29);
//The Integer 29 indicate the number of requests,
//hence, the number of concurrent threads volley will run on its Looper and
//Handler.
// Start the queue
mRequestQueue.start();
//Make request here我希望这对任何人都有帮助。
发布于 2018-02-24 08:04:48
可以,如果响应包含ID,它只会接受一次请求,那么您可以在JSON解析过程中获得列表ID。
https://stackoverflow.com/questions/48954856
复制相似问题