简体   繁体   English

Android Retrofit2:从异步延迟的http页面读取

[英]Android Retrofit2: read from async delayed http page

i'm using latest retrofit2 android library version and i have a problem getting a page which contain a single table that loads his data asynchronously. 我正在使用最新的retrofit2 android库版本,我在获取包含单个表的页面时遇到问题,该表以异步方式加载其数据。

i call the page -> page responds with 200 -> page start gathering data and shows it progressively. 我调用页面 - >页面响应200 - >页面开始收集数据并逐步显示。

if i call the retrofit2 interface, it grab sometimes 60 elements, other times 100 elements. 如果我调用retrofit2接口,它有时会抓取60个元素,有时会抓取100个元素。

if i load that page with any browser, it takes 2 seconds and shows 600 elements. 如果我用任何浏览器加载该页面,它需要2秒,并显示600个元素。

how can i delay retrofit2 (or okHttp) after he receive the 200 response? 如何在收到200响应后延迟retrofit2(或okHttp)?

Thank you 谢谢

You can use the @Streaming annotation which allows you to get the data as a stream. 您可以使用@Streaming注释,它允许您将数据作为流获取。 Take a look at this answer . 看看这个答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM