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 . 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 in my collection of Android helpers, , 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 with full source, and even a downloadable Android app for testing the functionality yourself.