Is there a built-in way to detect the Internet that is not connected to okhttp.?

Is there a built-in way to detect the Internet that is not connected to okhttp. I made my own implementation for this specific thing, but just wanted to know if something related to this was included in the source code?

+4
source share
2 answers

Since okhttp 2.5.0, if there is no Internet connection, then the control will fall into the onFailure () function of the okhttp callback class. There you can check the reason for the exception and do what you need. PS uses the enqueue method to execute the request.

+1
source

The fastest way I've found is

if (! Response.isSuccessful ())

, !

0

Source: https://habr.com/ru/post/1613192/


All Articles