我試圖使用BitmapFactory
代碼的URL(http://www.elifeshopping.com/images/stories/virtuemart/product/thumbnail (2).jpg)加載在我的Android應用程序圖像低於:如何解決java.net.MalformedURLException:協議未發現:在9安卓
try {
// ImageView i = (ImageView)findViewById(R.id.image);
bitmap = BitmapFactory.decodeStream((InputStream) new URL(url)
.getContent());
i.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
這裏我得到
05-03 15:57:13.156: W/System.err(1086): java.net.MalformedURLException: Protocol not found: 9
05-03 15:57:13.167: W/System.err(1086): at java.net.URL.<init>(URL.java:273)
05-03 15:57:13.167: W/System.err(1086):
at java.net.URL.<init>(URL.java:157).
請幫助告訴我做錯了什麼。
你應該打開URL連接 – Dharmendra
你從哪裏得到的URL。檢查你的變量url輸入字符串是以http://還是https://打印url字符串中的異常爲例 – user1369689
我在webservice中得到了url nd它開始於http只有 – Shruti