2017-10-05 7 views
0

retrofit2を使用してネットワークコールを行い、データを取得しています。このリンクを参照する再編成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メソッド内に配置します。それ以外の場合はAsyncTaskonResponseメソッド内に配置します。