[英]Android/Java: How to avoid duplicates in a RequestQueue?
My app sends data to a server every few minutes. 我的应用每隔几分钟将数据发送到服务器。 It works fine as long as I'm online. 只要我在线,它就可以正常工作。 When I'm offline in between, it seems like the stringRequests
are temporarily stored in the requestQueue
and fired all together as soon as I establish the internet connection. 当我在两者之间处于离线状态时,似乎stringRequests
临时存储在requestQueue
并在建立Internet连接后立即将其全部触发。
To avoid adding duplicates to the requestQueue
, I'm looking for something like the following pseudo-code: 为了避免将重复内容添加到requestQueue
,我正在寻找类似以下伪代码的内容:
if (!requestQueue.isRequestInQueue(stringRequest)) {
requestQueue.add(stringRequest);
}
I'd like to avoid using requestQueue.cancelAll()
. 我想避免使用requestQueue.cancelAll()
。
Any ideas how to avoid duplicates in a RequestQueue
? 任何想法如何避免RequestQueue
重复项? Thanks in advance! 提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.