Summary
In this chapter, we explored in detail the HttpUrlConnection
Android HTTP client and we built a basic and expandable asynchronous client to interact with HTTP web APIs.
In the first section, we exposed the main differences between the HttpUrlConnection
client and the deprecated Apache HTTP client available on pre-Marshmallow SDKs.
Next, we wrote the core classes and callback interfaces for our asynchronous client and we expanded our high-level client to interact with JSON and Web APIs. Additionally, we built the code to convert from our Java models to a JSON or an XML document.
Later, we learned how to configure the HTTP timeouts and to set up secure communications that are able to use our own signed certificates, keys, and CAs. In our example, we created and prepared an SSL context to be used to establish a secure channel based on a prepared Java secure keystore.
In the next chapter, we will introduce and explore the JNI (Java Native Interface) to create asynchronous tasks in native...