2012-04-11 37 views
0

我越來越MalformedURLException:協議未找到,當我試圖從URL加載圖像刺。當我粘貼該URL時,該圖像在瀏覽器中顯示。但不能在ImageView中顯示。我用這個代碼:獲取MalformedURLException:找不到協議?

public static Bitmap getBitmapFromURL(String src) { 

    try 
    { 
     URL url = new URL(src); 
     HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
     connection.setDoInput(true); 
     connection.connect(); 
     InputStream input = connection.getInputStream(); 
     Bitmap myBitmap = BitmapFactory.decodeStream(input); 

     return myBitmap; 
     } 
     catch (IOException e) { 
     e.printStackTrace(); 
     return null; 
    } 

    } 

請有人告訴我最新的問題?這對我很有幫助。

+0

你能告訴我們你的圖片網址嗎? – MByD 2012-04-11 04:59:18

+2

難道你不想錯過':'? – MByD 2012-04-11 05:03:01

+0

感謝大家的支持 – 2012-04-11 05:12:06

回答

3

它是一種

失蹤
http://74.208.68.90/webservice/images/image44.png 

您的代碼是確定的。

+0

嘿是的。你是對的。它來自webservice的錯誤。非常感謝。 – 2012-04-11 05:10:33

2

malformedexception來的時候有在您的網址一些問題

嘗試編碼與URL編碼器和protocall網址你的參數沒有找到節目 HTTP是從您的網址

String url = url +"/" + UrlEncoder.encode(param); 
0

我認爲這是「src」,可能有問題,

+0

這應該是一條評論。 – 2012-10-10 20:49:25