I need to access the Panoramio API to get some images based on the coordinates I've sent.
However, I'm having trouble receiving the JSON value.
After several searches, all indicate identical code, but the libraries used are discontinued. Is it possible to make a change to another library?
Code:
try {
final URI uri = new URI("http", url, null);
final HttpGet get = new HttpGet(uri);
final HttpClient client = new DefaultHttpClient();
final HttpResponse response = client.execute(get);
final HttpEntity entity = response.getEntity();
final String str = Utilities.convertStreamToString(entity.getContent());
final JSONObject json = new JSONObject(str);
parse(json);
} catch (final Exception e) {
Log.e(TAG, e.toString());
}
My conversion attempt:
URL urll = new URL(endPoint);
URLConnection connection = urll.openConnection();
InputStream inputStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder result = new StringBuilder();
String line;
while ((line = reader.readLine())!= null){
result.append(line);
}
final String str = result.toString();
final JSONObject json = new JSONObject(str);
Any help?
Thank you.