나는 때때로 오류없이 null을 반환하고, 때로는 그것을 작동합니다, 그러나이 방법다운로드 비트 맵 반환 널 가끔
public Bitmap downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.setReadTimeout(500000000);
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
return BitmapFactory.decodeStream(is,null,options);
} catch (IOException e) {
Log.e("log_tag", " Download image failed"+e.getMessage());
e.printStackTrace();
}
return null;
}
를 사용하여 웹에서 이미지를 검색하는 몇 가지 코드가 있습니다.
시간 초과를 많이 설정하려고 시도했지만 여전히 오류가 없습니다.
그것은 그 코드가 null을 반환 할 수있는 유일한 방법처럼 보인다 io 예외가있는 경우 스택 추적을 보시겠습니까? –
나는 예외를 잡으려고했지만 아무런 오류도 반환하지 않습니다. null – ericlee
http://stackoverflow.com/questions/3802820/bitmapfactory-decodestream-always-returns-null-and-skia-decoder-shows -decode-ret가 버그 인 것 같습니다. – ericlee