Pregunta

I am trying to fetch the xml file from flickr. Here is my code:

public static final String TAG = "FlickrFetchr";
public static final String ENDPOINT = "http://api.flickr.com/services/rest/";
public static final String API_KEY = "d4db9623ea909f4d2a01c8c9667fd378";  //secret=0c764276c114d52f
public static final String METHOD_GET_RECENT = "flickr.photos.getRecent";
public static final String PARAM_EXTRAS = "extras";
public static final String EXTRA_SMALL_URL = "url_s";
private static final String XML_PHOTO = "photo";

String url = Uri.parse(ENDPOINT).buildUpon().appendQueryParameter("method", METHOD_GET_RECENT)
    .appendQueryParameter("api_key", API_KEY)
    .appendQueryParameter(PARAM_EXTRAS, EXTRA_SMALL_URL)
    .build().toString();

String xmlString = getUrl(url);

When i debug, i see that the url is (Docs)and it works, the xml file is there. But i am getting an exception that says "Unable to resolve host "api.flickr.com": No address associated with hostname". Can anyone see the problem?

Thanks.

¿Fue útil?

Solución

Seeing as it was the case and you requested it, here's it as an answer.

If you are running an emulator, please restart it. This happens a lot. That exception is also thrown when the device has no internet connection.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top