Mike Szczys · May 28, 2013 at 07:00 am

Weather App by Example Teaches JSON, HTTP, and API Use

Developers who are just getting started can leap through the learning curve by reading code written by more experienced programmers. It becomes even more useful if you can read an explanation of what each code chunk does, like with this weather app tutorial. Francesco Angola, who also wrote that guide on using Httpclient, has done a great job of explaining how to use a website API, parse a JSON string, and present the results to the user.

Francesco starts by exploring the data available from the Open Weather Map API. Don’t be confused by that web page title. The goal here is to gather text data on the current weather conditions, not to display on an onscreen map. Entering the URL in a browser returns a JSON string, whose format he uses to craft a parser method with the help of the JSONObject and JSONArray classes. I consider this to be the core of the guide. The parser lays out a roadmap for how the data object will be stored. This technique is easily adapted anytime you’re working with the JSON format. From here, he uses HttpClient to grab the string that feeds the parser. The guide concludes by creating a bare bones activity that displays weather conditions on screen.

Head over to his blog for the full tutorial.

[Via Reddit]


_________
Want something on the XDA Portal? Send us a tip!

Mike Szczys

szczys is an editor on XDA-Developers, the largest community for Android users. Mike Szczys is a professional musician but spends all his free time working with hobby electronics. As Contributing Editor for Hackaday.com he became interested in Android as some of the early hardware hacks started popping up on the Internet. What followed was a gradually rising addiction to all things Android. View szczys's posts and articles here.
Faiz Malkani · Jul 2, 2015 at 08:41 pm · 1 comment

Mysterious GG1 Google Device Stops by FCC. Glass v2?

As the year progresses, we draw further away from Google's annual I/O conference, and closer to the time when the latest hardware from Mountain View is made available to the public. While I/O itself remains one of the most popular tech conferences, the hardware unveiling is a contrastively low-key post across social media, but nonetheless, remains an exciting and much awaited event. In the months leading up to the unveiling, a host of leaks take place, revealing various info about...

XDA NEWS
Faiz Malkani · Jul 2, 2015 at 04:54 pm · 3 comments

Material and Material Dark Hit Samsung’s Theme Store

The latest version of Touchwiz, launched alongside the Galaxy S6 and S6 Edge, was aimed at providing a vastly improved software experience in lieu of the bad reputation its predecessors had gained. While this iteration turned out to be a vast improvement in terms of lack of bloatware, fluidity and user experience, Samsung's OEM skin fell short in the aesthetics department by a long shot, abandoning a plethora of Material Design principles and leaving users wanting more. However, Theme Store...

XDA NEWS
Jack Jennings · Jul 2, 2015 at 01:09 pm · 4 comments

Swappa’s New App Helps You Value Your Device

There comes a sad time in everyone's life where you must part ways with your gadgets. Perhaps they are dropped from a height, carelessly hardbricked, or simply stashed in a drawer in favor of a shinier upgrade. Alternatively they might enter the world of the second-hand market, and become someone else's daily driver. Swappa is especially popular for this purpose here at XDA, where thousands of users trust the site enough to buy and sell their devices through it. In fact, we made...

XDA NEWS
Share This