Summary
Up to now, network communication is the most important part of the Development of the Internet. Network protocols emerge endlessly, but the most far-reaching impact is HTTP. From HTTP1.0 to HTTP2.0 iterated and updated with the needs of the society, queued and sent to the pipeline, half duplex to full duplex. For Android clients, the most commonly used HTTP implementation scheme is OkHttp, and the Google Android team also withdrew its own network library Volley early, but it has a fatal defect, because the parsing process will save the response in memory after the network comes back. It responds quickly to the cache but tends to blow up memory. So after Android N, the core code of OkHttp is adopted in the framework layer as a network request, which is equivalent to confirming OkHttp’s position in the network library. However, the Google Android team didn’t stop there, porting the Cronet network library to the Java platform from the Chromium team next door. Unlike OkHttp, which is implemented in Java, Cronet is implemented in Cpp, so it is naturally cross-platform and supports iOS, Android, and Frontend. For Android programmers familiar with Java/Kotlin development, reading Volley and OkHttp is imperative. Because Volley is a relatively simple network library compared to OKHttp, its design is suitable for starting network library reading, OKHttp implementation is more complete, more elegant code, reading experience.
Here are two images to get a feel for their design. Volley
OkHttp
If you know Volley and OkHttp, you should also know their API style and serialization
SOP:HTTP+XML(past) REST:HTTP+JSON(present) gRPC+protobuf(future)Copy the code
Reference
HTTP – Hypertext Transfer Protocol
Getting started with HTTP
Cronet is used to perform network operations