使用带参数的 URL从 Internet 下载 Android 图像???
此代码有效,但我不希望这样,我想使用带参数的 URL 来下载图像。(例如:URL= http://yahoo.com/record?ProductID=1)
如何更改此代码?请。
bmp = this.GetNetBitmap("http://avatar.csdn.net/B/D/5/1_redoffice.jpg");
public Bitmap GetNetBitmap(String url){
URL imageUrl = null;
Bitmap bitmap = null;
try{
imageUrl = new URL(url);
}
catch(MalformedURLException e){
Log.e("DownloadTimerTask", e.getMessage());
}
try{ HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(is); is.close();
}
catch(IOException e){
Log.e("DownloadTimerTask", e.getMessage());
}
return bitmap;
}