2016-01-20 46 views
-1

工作,我試圖從URL http://dbh_cache.s3.amazonaws.com/19445/34173cb38f07f89ddbebc2ac9128303f-33b64a2ed0f1ff4750f183b4f2a161b8.png圖片下載未在android系統

下載圖像這似乎URL的域名中含有下劃線導致圖像下載失敗。請讓我知道如果我是正確

+1

我要告訴你的魔法咒語,跟我說**如果一些圖像瀏覽器通過傳遞一個URL打開,然後你可以下載它。** – nobalG

+0

請發佈您的代碼 –

+0

我已經使用通用圖像加載器SDK下載圖像,並且當我將圖像URL更改爲其他內容(沒有任何下劃線)時,它的工作正常。 –

回答

0
public class LoadImage extends AsyncTask<String, String, Bitmap> { 


     ImageView img; 
     Bitmap bitmap; 
     Context con; 
     ProgressDialog pDialog; 
    public LoadImage(Context updateProfileActivity, 
       ImageView profileImageView) { 
      // TODO Auto-generated constructor stub 
     con = updateProfileActivity; 
     img = profileImageView; 
    } 
    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     pDialog = new ProgressDialog(con); 
     pDialog.setMessage("Loading Image ...."); 
     pDialog.show(); 

    } 
    protected Bitmap doInBackground(String... args) { 
     try { 
       bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent()); 

     } catch (Exception e) { 
       e.printStackTrace(); 
     } 
     return bitmap; 
    } 

    protected void onPostExecute(Bitmap image) { 

     if(image != null){ 
     img.setImageBitmap(image); 
     pDialog.dismiss(); 

     }else{ 

     pDialog.dismiss(); 
     // Toast.makeText(MainActivity.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show(); 

     } 
    } 
} 
+0

它也不工作。我也嘗試過使用NetworkImageLoader類,這樣我可以保存圖像以備將來使用 –

+0

showlog cat。或者你可以使用ImageLoader –