O'Reilly logo

Android Cookbook, 2nd Edition by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 allow HTTP/HTTPS ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required