本文主要根据代码实例来分析安卓客户端获取网络的图片。
1、获取image的通用方法,根据URL地址参数来获得
public class ImageService {
public static Bitmap getImage(String path) throws Exception{
URL url = new URL(path) ;
HttpURLConnection conn = (HttpURLConnection) url.openConnection() ;
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
if(conn.getResponseCode() == 200){
InputStream inStream = conn.getInputStream() ;
Bitmap bm = BitmapFactory.decodeStream(inStream) ;
return bm ;
}
return null;
}
}
2、该方法的变量可以根据具体内容进行修改
public void showimage(Ima