2017-10-05 73 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方法中。