我想从某个 URL 从网络中获取图像并将其显示在我的 ImageView 中。以下是我正在使用的代码:-
Bitmap bm = null;
try {
URL aURL = new URL("stringURL");
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
}catch (Exception e) {
// TODO: handle exception
}
iv.setImageBitmap(bm);
但我无法获得图像