Showing posts with label asynchronous. Show all posts
Showing posts with label asynchronous. Show all posts

Thursday, September 2, 2010

Asynchronous web request

Many good Android apps pull in some kind of external data to keep everything current. When making web requests for data, it is important to use asynchronous calls on a new thread so that the UI remains responsive to the user. Asynchronous calls do require a bit more code than synchronous calls, but it is a minimal amount and pays big dividends to the polish of the app.

There are 2 functions required for the call: 1) makeHTTPRequest and 2) handleHTTPResponse. Sample code for each of these is provided below.