Using Web Services

Android provides a full set of Java-standard networking APIs, such as the java.net.HttpURLConnection package, that you can use in your programs. The tricky part is to make the calls asynchronously so that your program’s user interface is responsive at all times.

Consider what would happen if you just make a blocking network call in the middle of your user interface code. Suddenly your application would not be able to respond to any events such as touches or button presses. It would appear hung to the user. Obviously, that’s something you want to avoid.

The java.util.concurrent package is perfect for this kind of work. First created by Doug Lea as a stand-alone library and later incorporated into Java 5, this package supports ...

Get Hello, Android, 4th 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.