私は時々それがエラーなしで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;
}
を使用してWebから画像を取得するいくつかのコードを持っています。
タイムアウトを大きく設定しようとしましたが、それでもエラーは発生しません。
ヌルを返すために、そのコードのための唯一の方法のように思えますio例外がある場合は、スタックトレースが表示されますか? –
私は試して例外をキャッチしましたが、エラーを返さないだけnullを返しました。 – ericlee
http://stackoverflow.com/questions/3802820/bitmapfactory-decodestream-always-returns-null-and-skia-decoder-shows -decode-retがバグのようです – ericlee