它給了我下面的錯誤當我嘗試當我嘗試加載圖像到機器人加載圖像,未知主機異常Android中
06-10 11:08:50.217: WARN/System.err(868): java.net.UnknownHostException: nopsa.hiit.fi
06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.lookupHostByName(InetAddress.java:497)
06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.getAllByName(InetAddress.java:256)
06-10 11:08:50.237: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)
06-10 11:08:50.237: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
06-10 11:08:50.277: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
06-10 11:08:50.277: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018)
06-10 11:08:50.297: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
我試圖訪問該文件是 http://nopsa.hiit.fi/pmg/viewer/images/thumb_132750728_8f0342f1ac_t.jpg
和我裏面的onDraw使用的代碼()是繼
try {
URL url = new URL(collectable.getIcon_url());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);
canvas.drawBitmap(img, 100, 100 , null);
} catch (Exception e) {
Log.d(TAG, "Image Load Failed");
e.printStackTrace();
}
而且你ofcourse有設備上的互聯網連接?只需檢查:-) – 2011-06-10 11:26:41
collectable.getIcon_url()是否返回正確的字符串?它是否與另一個模擬網址兼容?你必須測試這個。 – Egor 2011-06-10 11:27:37
其實,即時通訊模擬器上運行它?我以爲,因爲電腦有互聯網模擬器也有它 – dinesh707 2011-06-10 11:28:00