Skip to content

Instantly share code, notes, and snippets.

View tgvdinesh's full-sized avatar

Dinesh V tgvdinesh

View GitHub Profile
@tgvdinesh
tgvdinesh / Android API connection using HttpURLConnection
Last active August 29, 2015 14:15 — forked from anonymous/gist:1c04bf2423579e9d2dcd
The sample code provided is used to get data from any API in Android
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query