Chapter 12. Networked Applications
Networkingâone could talk about it for hours. In the context of Android, it is primarily about web services, which are services accessed by another program (your Android app) over the HTTP (âwebâ) protocol. Web services come in two flavors: XML/SOAP and RESTful. XML/SOAP web services are more formal and thus have significantly more overhead, both at development time and at runtime, but offer more capabilities. RESTful services are more lighterweight, and are not tied to XML: this chapter covers using JSON (JavaScript Object Notation) and other formats with web services.
Finally, while itâs not traditionally thought of as networking, Android also offers a more general âremote procedureâ (technically an inter-process Communication or IPC) mechanism layered on AIDL (the Android Interface Definition Language) that is actually used for communication among processes on the same âmachineâ (Android device); a recipe describing that is at the end of this chapter.
Choose your protocol wisely
While Java makes it easy to create network connections on any protocol, experience shows that HTTP (and HTTPS) is the most universal. If you use a custom protocol to talk to your own server, there are some users who will not be able to access your server. Bear in mind too that in some countries high-speed data is either not yet available or very expensive, whereas GPRS/EDGE is less expensive and more widely available. Most GPRS service providers only ...
Get Android Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.