This project focused on building
an application to use a JSON API to get data and display it to a user. The people involved
in creating this application include Andrew Ekstedt, Trevor Hammock and Miles Young.
In particular, the Android app features that were used include multiple activities (in
building a team, displaying a information about a Pokémon), a 3rd-party API (PokéAPI),
lifecycle methods (ViewModel), SharedPreferences (list sort), SQLite (teams), a polished
UI, and can launch the current Pokémon to have more information from the web.
Example
Weather App
This app was created to be able to work with the OpenWeatherMap API. However, since it was
a school project it is in a private repository so it can not be copied. Below is some code
snippits that were used in creating the project.
Canceling toasts
This code implements a method when clicking part of a text list to remove the toast
message if displaying, and show a new toast method.
Network Requests
One easy way to do network requests is to use okhttp.
Json Formatting
Another easy program to use is gson to deseralize JSON
into Java Objects.
Hidden API Key
For security reasons, it is good to hide an api
key
from an Android repo. This can be done by setting the key in gradle.properties as
Text_Api=”<key>” and then adding the file to .gitignore.
Then in build.gradle in the buildTypes, add the values buildConfigField(‘String’,
‘ApiKey’, Text_Api) and resValue(‘string’, ‘api_key’, Text_Api). Then, this can be
accessed with private final static String TEXT_APPID = BuildConfig.ApiKey;.