O
O
orbit0702019-06-14 08:10:11
Android
orbit070, 2019-06-14 08:10:11

In which case it is necessary to execute an http request in the main thread?

Hello.
Retrofit, if I understand correctly, allows you to make requests both in the main thread (execute method) and not in the main thread (enqueue method). Perhaps I am confusing the terms, I mean that execute is kind of like a blocking call, but enqueue is not. Several times I came across the statement that requests cannot be executed in the main thread. The question is, if you can't run requests on the main thread, then why does Retrofit have a method that executes them on the main thread?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
illuzor, 2019-06-14
@orbit070

Android does not allow requests to be made on the ui thread, none. With no exceptions.
Retrofit can be used not only for Android, but also for any java programs, and there requests in the main thread are allowed.
In android, you can create your own thread and execute a blocking request in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question