Repo for the practical session on Monday 15th June.
- Create a system for saving and reopening a 'Person' according to the activity lifecycle
- Add a way to change your biography
- Send your position to the server, and verify its returned value.
- Sort the list of other people based on distance
- Send a connection request. Server structure is the same and the URL starts with
/connection_request_server/
- See who has sent you a connection request
Retrofit: http://square.github.io/retrofit/
Android Developer site: http://developer.android.com/develop/index.html
Examples of how to use the Gson and Guava libraries included in the project.
Convert an object to and from a String:
Gson gson = new Gson();
Person person = getPersonFromSomewhere();
String personAsString = gson.toString(person);
Person newPerson = gson.fromJson(personAsString, Person.class);
Saving a String to the local storage. Option 1:
String personAsString = getPersonAsString();
File file = new File(getFilesDir(), "person.json");
Files.write(personAsString, file, Charset.forName("UTF-8"));
String readFromStorage = Files.toString(file, Charset.forName("UTF-8"));
Option 2, use SharedPreferences: http://developer.android.com/guide/topics/data/data-storage.html#pref