Created
August 20, 2015 21:46
-
-
Save naanT/fcd5607f1a471c74564e to your computer and use it in GitHub Desktop.
UriBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL url = new URL("http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7"); | |
final String FORECAST_BASE_URL = | |
"http://api.openweathermap.org/data/2.5/forecast/daily?"; | |
final String QUERY_PARAM = "q"; | |
final String FORMAT_PARAM = "mode"; | |
final String UNITS_PARAM = "units"; | |
final String DAYS_PARAM = "cnt"; | |
Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon() | |
.appendQueryParameter(QUERY_PARAM, params[0]) | |
.appendQueryParameter(FORMAT_PARAM, format) | |
.appendQueryParameter(UNITS_PARAM, units) | |
.appendQueryParameter(DAYS_PARAM, Integer.toString(numDays)) | |
.build(); | |
url = new URL(builtUri.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment