Replacement for deprecated DefaultHttpClient

前端 未结 6 1910
小鲜肉
小鲜肉 2020-12-30 06:55

I am using DefaultHttpClient in my current app.

I read this article which states that the DefaultHttpClient is deprecated: http://develope

6条回答
  •  死守一世寂寞
    2020-12-30 07:21

    Option 1 : Volley

    Android 1.6 (API Level 4) or higher

    Volley's benefits :

    • Automatic scheduling of network requests.
    • Multiple concurrent network connections.
    • Transparent disk and memory response caching with standard HTTP cache coherence.
    • Support for request prioritization.
    • Cancellation request API. You can cancel a single request, or you can set blocks or scopes of requests to cancel.
    • Ease of customization, for example, for retry and backoff.
    • Strong ordering that makes it easy to correctly populate your UI with data fetched asynchronously from the network.
    • Debugging and tracing tools.

    Option 2 : OkHttp

    OkHttp supports Android 2.3 and above. For Java, the minimum requirement is 1.7.

    Some of the features listed in its documentation :

    • HTTP/2 and SPDY support allows all requests to the same host to share a socket.
    • Connection pooling reduces request latency (if SPDY isn’t available).
    • Transparent GZIP shrinks download sizes.
    • Response caching avoids the network completely for repeat requests.

提交回复
热议问题