public static Bitmap getBitmap(String urlBitmap){
try {
URL url=new URL(urlBitmap);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
int responseCode = urlConnection.getResponseCode();
if(responseCode==200){
InputStream inputStream = urlConnection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
return bitmap;
}else{
Log.e("cx","请求码"+responseCode);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
关于handler请求网络图片的工具类
最新推荐文章于 2022-10-03 22:24:08 发布