
正文
【Android开发】URL[] 转成 bitmap[]
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
public static Bitmap[] getBitmapFromURL(String[] path) throws MalformedURLException { Bitmap[] b = new Bitmap[path.length]; for (int i = 0; i < path.length; i++) {
URL url = new URL(path[i]);
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection)url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
if(conn.getResponseCode() == 200){
InputStream inputStream = conn.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
b[i]=bitmap;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return b;
}







