I am currently working on an Android app and I am trying to connect to Flickr and grab photos from it. However, my HttpGet call fails completely. Here is my code:
HttpClient httpClient = new DefaultHttpClient();
String temp = restUrl.toString();
HttpGet httpGet = new HttpGet(temp);
try
{
HttpEntity httpEntity = httpClient.execute(httpGet).getEntity();
if (httpEntity != null)
{
InputStream inStream = httpEntity.getContent();
Reader in = new InputStreamReader(inStream);
BufferedReader bufferedReader = new BufferedReader(in);
StringBuilder sBuilder = new StringBuilder();
String stringReadline = null;
while ((stringReadline = bufferedReader.readLine())!=null)
{
sBuilder.append(stringReadline+"\n");
}
queryResult = sBuilder.toString();
}
}
My temp stores the string “http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=467ae9bf5926d10c684d4f47d7da6434&tags=new%20york&per_page=5&page1”
The call works fine when I make the call in my browser (It returns the xml file I am expecting). However, it does not work when I am making the call from my android app. I have added the Internet permissions line in my android manifest file.
I would really appreciate any help.
Thanks,
Ro
Yup didn’t read your full question before I posted my answer.
I have used code below to retrieve content and it works with no problems.