0

We are using retrofit2 to make network calls and get our data.

With reference to this link

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.

Now is there any way during a call to execute method to make retrofit2 request we can specify which type of Callback is to be used ?

Thanks

Relsell
  • 771
  • 6
  • 18

1 Answers1

0

You don't need to specify what type of callbacks you need to use. Just use regular callback for both cases.

If you want the callback to be executed in the UI thread, just place your code inside the onResponse method, otherwise place an AsyncTask inside the onResponse method.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59