Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

okHTTP used internally on Android devices >4.4 when using HttpUrlConnection

I am not sure if something applies to the Android version installed on the phone or the SDK version I am compiling against.

It appears that HTTPUrlConnection is now internally using OkHttp on devices > 4.4. So if my app compiles against 4.4 but can work on 4.0, if it is launched on 4.0 would it still use OkHttp underneath ?

Are there still some advantages of using OkHttp as a direct implementation and bypassing HttpUrlConnection ?

like image 758
Martin Avatar asked Oct 18 '25 16:10

Martin


1 Answers

if it is launched on 4.0 would it still use OkHttp underneath ?

Only if you directly use OkHttp's API, via a copy of OkHttp that you package with your app.

While Google probably has a time machine, they have not been using it to "retcon" Android and put OkHttp in as the HttpUrlConnection implementation in Android versions prior to Android 4.4.

I presume there are still some advantages of using OkHttp as a direct implementation and bypassing HttpUrlConnection ?

I like OkHttp's native API better. It offers SPDY and HTTP/2 support, which is useful if you are talking to servers that in turn support those.

like image 75
CommonsWare Avatar answered Oct 21 '25 06:10

CommonsWare