Skip to Content
Android Cookbook
book

Android Cookbook

by Ian F. Darwin
April 2012
Intermediate to advanced
770 pages
16h 48m
English
O'Reilly Media, Inc.
Content preview from Android Cookbook

Chapter 13. Networked Applications

13.1. Introduction: Networking

Ian Darwin

Discussion

Networking. One could talk about it for hours. In the Android context 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 capability. RESTful services are much lighter weight, and are not tied to XML: we have recipes on using JSON (JavaScript Object Notation) and other formats with web services.

Choose your protocol wisely

While Java makes it easy to create network connections on any protocol, experience shows that HTTP (and HTTPS) are the most universal. If you use a custom protocol talking to your own server, there are some users who will not be able to access your server. Bear in mind that in some countries, high-speed data (a.k.a. 3G) 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 connections, often through a WAP proxy. That being said, there may be things you need to do that can’t be done via HTTP—for example, because the protocol demands a different port number (e.g., SIP over port 5000). But do try to make HTTP your first choice when you can—you’ll include more customers.

13.2. Using a RESTful Web Service

Ian

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Android Cookbook, 2nd Edition

Android Cookbook, 2nd Edition

Ian F. Darwin
Android in Practice

Android in Practice

Michael Galpin, Charlie Collins, Matthias Kaeppler
Android Application Development

Android Application Development

Rick Rogers, John Lombardo, Zigurd Mednieks, G. Blake Meike

Publisher Resources

ISBN: 9781449335786Errata Page