android 加载 网络图片

HttpURLConnection connection = (HttpURLConnection) url.openConnection();      connection.setDoInput(true);       connection.connect();  InputStream input = connection.getInputStream(); bitmap[i] = BitmapFactory.decodeStream(input); System.out.println("the bitmap is +bitmap[i]);
SkImageDecoder::Factory returned null the bitmap is null
使用 HttpURlConnection 加载  可能return null
HttpGet httpRequest = new HttpGet(url); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = (HttpResponse) httpclient                     .execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(entity); InputStream is = bufferedHttpEntity.getContent(); Drawable d = Drawable.createFromStream(is, "");
就不会发生 这种情况

你可能感兴趣的:(android)