5COSC005W - Tutorial 6 Exercises

As part of this tutorial for this week, you should complete ALL the tasks described below: (make sure that you ask questions to your tutor for anything that you do not understand or if you are stuck at any point):

  1. In this example you will be implementing an Android weather application utilising the https://api.openweathermap.org/. Goto to the website and sign in for a free account (https://openweathermap.org/price and click on the Get API Key under the free subscription plan). You need this in order to obtain the API key (which might take up to 2 hours to be activated, make sure you provide an email address and confirm your registration when you receive the email).

The documentation of the format for URL queries sent is at: https://openweathermap.org/current.

The URL you should be using for a query looks like this:

https://api.openweathermap.org/data/2.5/weather?q=London,UK&units=metric&appid=YOUR_OWN_API_KEY

Make sure that in the above query you replace your own API key, which you obtain after the registration.

Implement all the necessary code so that your application will be connecting to the above Web service and get the current weather for London and display the current temperature and the "feels like" temperature.

  1. Modify your weather application so that the user can enter the location he/she would like to check the temperature for.
  2. Extend your application so that it also displays the sunrise, sunset and description (e.g clear sky) information from the JSON data received.
  3. Use an SQLite database to save all of the retrieved weather forecasts in a table. Extend the application with a button See historical data which will display the weather for the chosen city from the database table, i.e. the displayed data will include date, time and the weather at that point in time.