Due: Wednesday February 2, 11pm.
Upload Instructions: Upload to this CrowdGrader assignment. General upload instructions are available here.
We are going to build a simple app that interrogates a weather API, and reports the weather conditions for the location.
To get the weather, you need to issue an HTTP GET call to this URL:
The response looks like this.
It can be a server error (500).
It can be an application error:
{"response": {"result": "error"}}
Or else, it can be a proper weather response, which looks similar to this:
{"response": {"conditions": {"wind_gust_mph": 0, "temp_f": 52.299999999999997, "observation_location": {"city": "High St, Santa Cruz", "full": "High St, Santa Cruz, California", "elevation": "141 ft", "country": "US", "longitude": "-122.034447", "state": "California", "country_iso3166": "US", "latitude": "36.977425"}, "temp_c": 11.300000000000001, "relative_humidity": "90%", "weather": "Clear", "dewpoint_c": 10, "windchill_c": "NA", "pressure_mb": "1025", "windchill_f": "NA", "dewpoint_f": 50, "wind_mph": 0.0}, "result": "ok"}}
(Note the "result": "ok"
: this is what tells you that this response is valid).
You have to build an application consisting of one activity.
When you open the activity, there is a button that says: "Get Weather Conditions".
When you click it, it has to do the server call, get the weather conditions, and display them.
You need to display at least
You can display more if you wish.
If an error occurs, you have to advise the users with some kind of error string, and you have to let them try again to get the weather.
That's it. A simple assignment on doing http calls.
Please:
You might find useful these other URLs:
Do not use them in the homework submission, but you may find them useful in testing. After the submission deadline, these functions will work like the standard get_weather
.