would now like to create an accompanying Android app to provide smartphone and tablet users an easy way to look up and display restaurants.
Your task is to develop this app. It has the following requirements:
- A user should be able to view a map of their current area on their smartphone or tablet. This map should always be positioned at the user’s current position on the earth; when the user changes their physical location, the map should reflect this.
- A user should be able to add a new restaurant at their current location. The user should be able to input the following information:
– restaurant name;
– restaurant address;
– cuisine (Indian, Chinese, Italian etc);
– a rating (1-10).
The input should be done using a separate activity. The restaurant should appear on the map as a marker as soon as it has been added.
- A user should be able to save all restaurants added so far to file, via a menu option.
- The user should be able to set a preference which determines whether restaurants are saved to file automatically when added. If set, all current restaurants must be saved to file.
- A user should be able to load all existing restaurants from file. These should be displayed on the map as markers.
- The user should be able to load restaurants from the web. You should connect to the following web service:
http://www.free-map.org.uk/course/mad/ws/get.php?year=18&username=user002&format=XXX
(XXX may be either “json” or “csv”, returning the data as JSON or CSV respectively).
The username=user002 filters out the restaurants so that only restaurants added by the user “user002” are retrieved; you may also supply the value “all” to get all restaurants. You will be allocated your own username.
When the restaurants are loaded they should be shown on the map as markers.
- If the appropriate preference is set (see requirement 4), a restaurant should be saved to the web after it has been added to the map.
To save to the web, connect to the following web service with a method of POST:
http://www.free-map.org.uk/course/mad/ws/add.php
The following POST parameters must be specified:
– username (your username as described in Requirement 6);
– name (the restaurant name)
– cuisine (the restaurant cuisine)
– address (the restaurant address)
– rating (the restaurant rating)
– lat (the latitude)
– lon (the longitude).
– year. This must have the value “18”. This is so that the web service knows that it is dealing with data relating to this year’s assignment, not last year’s.
- Allow the user to see a list of all restaurants in memory so far (loaded in from file, downloaded from the web, or added by the user). When the user selects an entry in this list, the map should be centred on that restaurant. This should be done using fragments. so that either on a tablet or in landscape mode on a phone (your choice), the list appears on the same screen as the map, while otherwise, the list appears in a separate activity.
Ideally, each entry in the list should show not only the restaurant’s name, but also its cuisine (Indian, Italian, Chinese etc), on a separate line in smaller font.
Tasks
I – Coding task
For each requirement above, implement the requirement using the Android API.
II – Discussion task
Discuss how you have used some or all (as appropriate, depending on the code you have completed) of the following Android topics in your assignment (one or two paragraphs each). Include technical detail on how your code using each technology works.
This discussion must relate to your assignment answer rather than being simply a theoretical discussion. It cannot simply be a copy or a paraphrasing of the lecture notes.
- a) How you have used XML layout files in your application
- b) Use of findViewById()
- c) Communication between activities using Intents and Bundles, and result codes where appropriate
- d) Use of preferences
- e) File I/O
- f) Network communication, including both GET and POST requests as appropriate
- g) JSON or CSV parsing, as appropriate
- h) Use of fragments