3

I just found out that Android's recommended http client HttpUrlConnection doesn't support HTTP/2.

Is there a specific reason not to use HTTP/2 on Android?

Daniele B
  • 19,801
  • 29
  • 115
  • 173
  • 2
    It supported SPDY years ago, which was the precursor to HTTP/2. How are you determining that HTTP/2 is not supported? OkHttp is the better choice, for lots of reasons, though. – CommonsWare Oct 05 '18 at 21:26
  • 1
    I am monitoring the https requests on the server side. The requests coming from the Android app using HttpUrlConnection are always HTTP/1.1, even on Android 9. While from the iOS app they are always HTTP/2. – Daniele B Oct 05 '18 at 21:30

1 Answers1

8

You can use OkHttp if you want to take advantage of HTTP/2:

https://github.com/square/okhttp

It's superior to HttpUrlConnection anyway. If you're doing anything at all complicated, like getting complex JSON responses from a web API, I'd recommend Retrofit:

https://square.github.io/retrofit/

nasch
  • 5,330
  • 6
  • 31
  • 52