我们使用retrofit2进行网络调用并获取数据。
参考此链接
https://square.github.io/retrofit/2.x/retrofit/index.html?retrofit2/Callback.html
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请求的过程中,我们是否可以指定使用哪种类型的回调?
谢谢
发布于 2017-10-05 11:27:38
您不需要指定需要使用的回调类型。对于这两种情况,只需使用常规回调。
如果希望在UI线程中执行回调,只需将代码放在onResponse方法中,否则将AsyncTask放在onResponse方法中。
https://stackoverflow.com/questions/46576636
复制相似问题