首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重新加载改造2

重新加载改造2
EN

Stack Overflow用户
提问于 2017-10-05 09:45:15
回答 1查看 29关注 0票数 0

我们使用retrofit2进行网络调用并获取数据。

参考此链接

https://square.github.io/retrofit/2.x/retrofit/index.html?retrofit2/Callback.html

代码语言:javascript
复制
Callback methods are executed using the Retrofit callback executor. When none is specified, the following defaults are used:

Android: Callbacks are executed on the application's main (UI) thread.
JVM: Callbacks are executed on the background thread which performed the request.

现在,在调用execute方法发出retrofit2请求的过程中,我们是否可以指定使用哪种类型的回调?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-10-05 11:27:38

您不需要指定需要使用的回调类型。对于这两种情况,只需使用常规回调。

如果希望在UI线程中执行回调,只需将代码放在onResponse方法中,否则将AsyncTask放在onResponse方法中。

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

https://stackoverflow.com/questions/46576636

复制
相关文章

相似问题

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