Tony Lukasavage

Caffeine. Whiskey. Code. Mostly the last one.

Waiting for Android: UrlJsonAsyncTask

When creating my MMA fighter search app for Android, Knuckle Head, I created a class that I have reused a few times since. Its called UrlJsonAsyncTask and the code necessary to use it is available in my com.savagelook.android project on Github. The following excerpt describes the problem it was built to solve:

I can’t even count how many times I’ve had to load a ProgressDialog in Android, query JSON from a remote URL, and then return control back to the app once the query has completed. It’s an incredibly common control flow, and one I’m sick of doing over and over again. I’m sure I’m not alone. In effort to keep this a DRY situation, the class UrlJsonAsyncTask in my collection of Android helpers, com.savagelook.android, is dedicated to the aforementioned task. It reduces what can be an 80+ line of code endeavor, per task, down to about 15 or less.

For the rest of the article, head over to the full article at BuildMobile.com and check it out. The full article includes a full explanation of the code, a test project with full source, and even a downloadable Android app for testing the functionality yourself.