1

我正在使用这个http://www.survivingwithandroid.com/2013/05/build-weather-app-json-http-android.html教程来学习如何在我的应用程序中使用天气服务。我运行本教程,它工作正常。但我有一个问题。无法加载图标。Logcat 错误是

java.io.FileNotFoundExeption: http://openweathermap.org/img/w/ at libcore.net.http.HttpURLConnectionTmpl.getInputStream(HttpURLConnctionTmpl.java:186) 

当我在 Chrome 中打开此链接时,我可以看到图像,所以我不知道为什么找不到它。代码在那里https://github.com/survivingwithandroid/Surviving-with-android/tree/master/WeatherApp 文件“WeatherHttpClient.java”的第 87 行错误

4

3 回答 3

0

add .png file ext

example

con = (HttpURLConnection) ( new URL(IMG_URL + code +".png")).openConnection();

于 2014-06-21T06:31:49.263 回答
0

您正在尝试将目录加载为文件流。不知道为什么这会导致 FileNotFoundException 但值得尝试使用 URL:http://openweathermap.org/img/w/<one-of-the-files>.png

至少该文件应该可以打开。

于 2013-09-25T19:58:48.100 回答
0

面临同样的问题只需更改您的网址,如下所示,其工作正常 https://openweathermap.org/img/wn/50d@4x.png

于 2021-07-17T07:49:36.563 回答