2017-10-05 74 views
0

我们正在使用retrofit2进行网络调用并获取我们的数据。Regarading retrofit 2

参照此链接

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. 

现在有没有在通话过程中的任何方式来执行方法,使我们可以指定哪些类型的回调,是retrofit2请求中使用?

谢谢

+0

这可能是你在找什么https://stackoverflow.com/a/33384551/7689086 –

回答

0

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

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