Why HTTP/2 is not supported by Android's HttpU

2019-06-06 05:19发布

问题:

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?

回答1:

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/