[英]Multi-Part request in background
This is more a question of software that a programming question, so making a multi-part request making that with the app open makes the user wait a bit, I can do a background task but I'm trying to keep the app api in 21(Android), what do a make in app open or I make a background that works with the app close and send the values until the file is ended?这更像是一个软件问题而不是一个编程问题,因此在应用程序打开的情况下发出多部分请求会使用户稍等片刻,我可以执行后台任务,但我试图将应用程序 api 保持在 21 (Android),在应用程序中打开什么或我关闭与应用程序一起使用的背景并发送值直到文件结束?
There is a lot of cases you can do.You can use: RxJava or Kotlin coroutines (if you use Kotlin).有很多情况你可以做。你可以使用: RxJava或Kotlin 协程(如果你使用 Kotlin)。 Also you can try to use Koltin flow (similar to rxJava) but it's experimental yet.
您也可以尝试使用 Koltin flow(类似于 rxJava),但它还处于实验阶段。 If you need to make requests to rest api one by one you can do it with coroutines.
如果您需要一一向 rest api 提出请求,您可以使用协程来完成。 All you need it's:
你所需要的只是:
For rest api calls I recommend using Retrofit .对于 rest api 调用,我建议使用Retrofit 。 This library can deserialise responses to pojo (for example with GsonConverterFactory).
这个库可以反序列化对 pojo 的响应(例如使用 GsonConverterFactory)。 Also you can use "suspend" there
你也可以在那里使用“暂停”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.