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;
}
【Android开发】URL[] 转成 bitmap[]
猜你喜欢
转载自www.cnblogs.com/neo-java/p/10184926.html
今日推荐
周排行