首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Volley获取列表中多个in的响应

使用Volley获取列表中多个in的响应
EN

Stack Overflow用户
提问于 2018-02-24 03:23:31
回答 2查看 33关注 0票数 0

我有一个ID列表,我想获取该列表中每个ID的数据。是否可以使用volley或任何其他网络库,而不必在列表循环时调用请求,以节省执行时间?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-02-26 15:33:04

这就是我到目前为止所做的工作。要发送每个ID的多个网络请求,需要一个新的RequestQueue构造函数(用于volley)。` RequestQueue mRequestQueue = Volley.newRequestQueue(mContext);

代码语言:javascript
复制
        // 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

我希望这对任何人都有帮助。

票数 0
EN

Stack Overflow用户

发布于 2018-02-24 08:04:48

可以,如果响应包含ID,它只会接受一次请求,那么您可以在JSON解析过程中获得列表ID。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48954856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档