Consuming HTTP Services

Android applications and mobile applications in general are small apps with a lot of functionality. One of the ways that mobile apps deliver such rich functionality on such a small device is that they pull information from various sources. For example, the T-Mobile G1 comes with the Maps application, which provides seemingly sophisticated mapping functionality. We, however, know that the application is integrated with Google Maps and other services, which provide most of the sophistication.

That said, it is likely that the applications you write will also leverage information from other applications. A common integration strategy is to use HTTP. For example, you might have a Java servlet that provides services you want to leverage from one of your Android applications. How do you do that with Android? Interestingly, the Android SDK ships with Apache's HttpClient (, which is universally used within the J2EE space. The Android SDK ships with a version of the HttpClient that has been modified for Android, but the APIs are very similar to the APIs in the J2EE version.

The Apache HttpClient is a comprehensive HTTP client. Although it offers full support for the HTTP protocol, you will likely utilize HTTP GET and POST. In this section, we will discuss using the HttpClient to make HTTP GET and HTTP POST calls.

iPhone and iPad App Cash

iPhone and iPad App Cash

Discover how a single application could generate $1000's of dollars, instantly. The simple, low cost system for outsourcing app development to freelancers. How to quickly evaluate applications so you can create a high profit one of your very own. The fastest way to leverage the popularity of iPhone and iPad apps to skyrocket your income. Top methods for promoting your application for maximum exposure.

Get My Free Ebook

Post a comment