Android通过URL加载网络图片

  public static Bitmap getBitmap(String path) throws IOException {

        URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
if (conn.getResponseCode() == 200){
InputStream inputStream = conn.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
return bitmap;
}
return null;
}

最后直接ImageView.setImageBitmap(bitmap);

上一篇:asp.net时间范围查询


下一篇:关于JDBC 连接Access 数据库