1
I need to access the API Panoramio to fetch some images according to the sent coordinates.
However I am having trouble receiving the JSON value.
After several searches, all indicate code identical to this, but the libraries used are discontinued. It is possible to make a change to any other 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 attempt at conversion:
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);
Some help?
Thank you.
Yes, however I preferred the use of native Android libraries...
– jsantos1991